This repository was archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
2. Getting Started
Fatih Kılıç edited this page May 25, 2019
·
7 revisions
Due that class is not using any hard coded method you can call all methods but you have to follow some rules.
- You have to put dots (
.) instead of slashes (/) - You have to put HTTP method at the end with capital letters (
.GET())
Since the whole code built on top of on requests library you can use same keyword arguments from requests.request
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()POST request to https://httpbin.org/anything/endpoint with data
from anyapi import AnyAPI
base_url = 'https://httpbin.org'
api = AnyAPI(base_url)
api.anything.endpoint.POST(data={'username': 'FKLC', 'password': 'password'})api = AnyAPI(base_url, auth=('user', 'password'))
# equals to
api = requests.Session()
api.auth = ('user', 'password')