Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

2. Getting Started

Fatih Kılıç edited this page May 25, 2019 · 7 revisions

Making requests

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())

Method Arguments

Since the whole code built on top of on requests library you can use same keyword arguments from requests.request

Examples

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'})

Setting attributes of Session instance

api = AnyAPI(base_url, auth=('user', 'password'))

# equals to

api = requests.Session()
api.auth = ('user', 'password')
Clone this wiki locally