Giter VIP home page Giter VIP logo

fnbr-api's Introduction

FNBR API

A python type API module for FNBR.co.

Asyncronous and non-asyncronous

Documentation

Api keys

You will need a twitter account to request an api key. To get yours send a request to the great guys over at fnbr.co in their api channel. Simply send a message along the lines of: Hey I would like to request an api key for [YOUR REASON] my twitter is @[YOUR TWITTER HANDLE].

Installing

Installing is simple using PyPi.

pip install -U fnbr-api

You can then import using

import fnbr # blocking

or

import aiofnbr # asyncronous non-blocking

Examples

fnbr (Blocking)

All for python 3.5

Retreive today's shop

import fnbr

apikey = 'YOUR_API_KEY'
request = fnbr.Shop(apikey)
response = request.send()
if response.status == 200 and response.type == fnbr.constants.SHOP_TYPE:
  shop = response.data
  print('Shop for: {0}'.format(shop.date))
  print('Daily items:')
  for item in shop.daily:
    print('\t{0}: {1}'.format(item.name,item.price))
  print('Featured items:')
  for item in shop.featured:
    print('\t{0}: {1}'.format(item.name,item.price))
else:
  print('Error getting shop')

Search for an image

import fnbr

apikey = 'YOUR_API_KEY'
itemname = 'Rex' # the search is case sensitive
itemtype = 'outfit' # must be one of 'emote','glider','emoji','loading','outfit','pickaxe','skydive','umbrella' or 'misc'. not case sensitive
itemlimit = 1 # integer between 1 and 15
request = fnbr.Images(apikey,search=itemname,type=itemtype,limit=itemlimit)
response = request.send()
if response.status == 200 and response.type == fnbr.constants.IMAGE_TYPE:
  print('Results:')
  imagedata = response.data
  for item in imagedata.results:
    print('{0}: {1}'.format(item.name,item.price))
else:
  print('Error searching images')

Get statistics

import fnbr

apikey = 'YOUR_API_KEY'
request = fnbr.Stat(apikey)
response = request.send()
if response.status == 200 and response.type == fnbr.constants.STATS_TYPE:
  statdata = response.data
  print('Total cosmetics: {0}'.format(statdata.totalCosmetics))
else:
  print('Error getting stats')

aiofnbr (non-blocking)

Retreive today's shop

import aiofnbr
import asyncio

loop = asyncio.get_event_loop()
apikey = 'YOUR_API_KEY'
request = fnbr.Shop(apikey)
response = loop.run_until_complete(request.send())
if response.status == 200 and response.type == fnbr.constants.SHOP_TYPE:
  shop = response.data
  print('Shop for: {0}'.format(shop.date))
  print('Daily items:')
  for item in shop.daily:
    print('\t{0}: {1}'.format(item.name,item.price))
  print('Featured items:')
  for item in shop.featured:
    print('\t{0}: {1}'.format(item.name,item.price))
else:
  print('Error getting shop')

Search for an image

import aiofnbr
import asyncio

loop = asyncio.get_event_loop()
apikey = 'YOUR_API_KEY'
itemname = 'Rex' # the search is case sensitive
itemtype = 'outfit' # must be one of 'emote','glider','emoji','loading','outfit','pickaxe','skydive','umbrella' or 'misc'. not case sensitive
itemlimit = 1 # integer between 1 and 15
request = fnbr.Images(apikey,search=itemname,type=itemtype,limit=itemlimit)
response = loop.run_until_complete(request.send())
if response.status == 200 and response.type == fnbr.constants.IMAGE_TYPE:
  print('Results:')
  imagedata = response.data
  for item in imagedata.results:
    print('{0}: {1}'.format(item.name,item.price))
else:
  print('Error searching images')

Get statistics

import aiofnbr
import asyncio

loop = asyncio.get_event_loop()
apikey = 'YOUR_API_KEY'
request = fnbr.Stat(apikey)
response = loop.run_until_complete(request.send())
if response.status == 200 and response.type == fnbr.constants.STATS_TYPE:
  statdata = response.data
  print('Total cosmetics: {0}'.format(statdata.totalCosmetics))
else:
  print('Error getting stats')

Links

fnbr-api's People

Contributors

douile avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

loukious

fnbr-api's Issues

image

request = fnbr.Image(apikey,search=itemname,type=itemtype,limit=itemlimit)
AttributeError: module 'fnbr' has no attribute 'Image'

Type is optional for /api/images

Just thought I'd open this issue to clarify an error in the fnbr api documentation which is my fault - I have since fixed & updated fnbr.co/api/docs too.
The type argument is optional and is fine to be omitted from a request.

Also, good job on a great resource, your wiki is really good ๐Ÿ‘

OMG

AttributeError: module 'fnbr' has no attribute 'STAT_TYPE'

NameError

request = fnbr.Images(apikey,search=itemname,type=itemtype,limit=itemlimit)
NameError: name 'fnbr' is not defined

search error Images

when trying to follow the example of searching for Images, return a "bounds" error.

Captura de tela em 2020-02-26 12-30-04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.