AnyAPI is a library that helps you to write any API wrappers with ease and in pythonic way.
Based on the "HTTP" category.
Alternatively, view AnyAPI alternatives based on common mentions on social networks and blogs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of AnyAPI or a related project?
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.
But most importantly in AnyAPI almost everything is modular!
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.
There is a lot of libraries you can find out there for example Uplink, Hammock and many more...
Library on PyPI so just run
pip install anyapi
Do not miss the trending, packages, news and articles with our weekly report.