All Projects → FKLC → Anyapi

FKLC / Anyapi

Licence: mit
AnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Anyapi

Slack
🎉✨ Slack API client for Node and browsers.
Stars: ✭ 903 (+616.67%)
Mutual labels:  api, api-client, api-wrapper
Virustotal Api
Virus Total Public/Private/Intel API
Stars: ✭ 189 (+50%)
Mutual labels:  api, api-client, api-wrapper
Coingecko Api
A Node.js wrapper for the CoinGecko API with no dependencies.
Stars: ✭ 159 (+26.19%)
Mutual labels:  api, api-client, api-wrapper
Alpaca
Given a web API, Generate client libraries in node, php, python, ruby
Stars: ✭ 2,447 (+1842.06%)
Mutual labels:  api, api-client, apis
Hubspot Php
HubSpot PHP API Client
Stars: ✭ 273 (+116.67%)
Mutual labels:  api, api-client, api-wrapper
Coinapi Sdk
SDKs for CoinAPI
Stars: ✭ 238 (+88.89%)
Mutual labels:  api, api-client, apis
Binance
A .NET Standard Binance API library.
Stars: ✭ 199 (+57.94%)
Mutual labels:  api, api-client, api-wrapper
Pizzly
The simplest, fastest way to integrate your app with an OAuth API 😋
Stars: ✭ 796 (+531.75%)
Mutual labels:  api, api-client, api-wrapper
Apipie
Transform api declaration to js object for frontend. Inspired by VueRouter, koa-middleware and axios.
Stars: ✭ 29 (-76.98%)
Mutual labels:  api, api-client, api-wrapper
Goodreads Api Node
Goodreads API wrapper for node.js
Stars: ✭ 72 (-42.86%)
Mutual labels:  api, api-wrapper
Openvulnapi
Documentation and Tools for Cisco's PSIRT openVuln API
Stars: ✭ 73 (-42.06%)
Mutual labels:  api, api-client
Google Searchconsole
A wrapper for the Google Search Console API.
Stars: ✭ 83 (-34.13%)
Mutual labels:  api, api-client
Newsapi
A python wrapper for News API.
Stars: ✭ 71 (-43.65%)
Mutual labels:  api-client, api-wrapper
Igdb
Go client for the Internet Game Database API
Stars: ✭ 65 (-48.41%)
Mutual labels:  api, api-client
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (-38.1%)
Mutual labels:  api, api-client
Slacko
A neat interface for Slack
Stars: ✭ 64 (-49.21%)
Mutual labels:  api, api-client
Discord.jl
The Julia Discord API Wrapper
Stars: ✭ 93 (-26.19%)
Mutual labels:  api, api-wrapper
Bluelinky
An unofficial nodejs API wrapper for Hyundai bluelink
Stars: ✭ 94 (-25.4%)
Mutual labels:  api, api-wrapper
Redux Api Call
One declarative API to create reducers, action creators and selectors for any API calls
Stars: ✭ 63 (-50%)
Mutual labels:  api, api-client
Rapidql
Query multiple APIs and DBs and join them in a single query
Stars: ✭ 91 (-27.78%)
Mutual labels:  api, api-client

AnyAPI

Travis (.org) Code Climate maintainability Code Climate coverage PyPI - Downloads PyPI - Python Version

AnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.

Features

  • Have better looking code using dynamic method calls.
  • Filters to help you to modify request, raise errors or log requests instead of writing functions everywhere.
  • Scoped calls to raise errors and take action if necessary.
  • Automatic retrying if the condition met with what you passed.
  • Built-in rate limit proxy changer. (you can write your own proxy handler)
  • Since it is built on top of requests anything compatible with it is compatible with AnyAPI.

But most importantly in AnyAPI almost everything is modular!


Examples

Making GET request to https://httpbin.org/anything/endpoint

from anyapi import AnyAPI


base_url = 'https://httpbin.org'
api = AnyAPI(base_url)

api.anything.endpoint.GET()

As you can see dots are pretended as slash and at the end you should put dot and HTTP method you want to use in capital letters.


Setting header before every request

import datetime
from anyapi import AnyAPI


def set_date_as_header(kwargs):
    now = datetime.datetime.now()
    kwargs['headers'].update({'date': now.strftime('%B %d %Y')})

    return kwargs

api = AnyAPI('https://httpbin.org')
api._filter_request.append(set_date_as_header)

print(api.anything.endpoint.GET().json())
# output
{
   'args': {},
   'data': '',
   'files': {},
   'form': {},
   'headers': {
      'Accept-Encoding': 'identity',
      'Connection': 'close',
      'Date': 'January 16 2019',
      'Host': 'httpbin.org'
   },
   'json': None,
   'method': 'GET',
   'origin': 'XX.XX.XX.XX',
   'url': 'https://httpbin.org/anything/endpoint'
}

As you can see filter worked as expected and set Date header.


Changing proxy automatically after they reach their rate limit

from anyapi import AnyAPI
from anyapi.proxy_handlers import RateLimitProxy

proxy_configuration = {
  'default': proxy0,
  'proxies': [proxy0, proxy1, proxy2,....], # don't forget to add default proxy!
  'paths': {
    '/anything': rate_limit0,
    '/anything/endpoint': rate_limit1
  }
}

api = AnyAPI('https://httpbin.org', proxy_configuration=proxy_configuration, proxy_handler=RateLimitProxy)

for i in range(10):
  print(api.anything.endpoint.GET().json())

If you check output of the all them you can see proxy changes when it reaches limit.

This library is not a new thing

There is a lot of libraries you can find out there for example Uplink, Hammock and many more...


Installation

Library on PyPI so just run

pip install anyapi

To learn more about AnyAPI check wiki page

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].