1. Visão Geral

Smart Rest Client Fis a python wrapper to perform requests to Rest APIs using objects to request endpoints and their methods

GET: List or Retrieve
POST: Create
UPDATE: Full Update
PATCH: Partial Update

2. Configurações

in the core folder of your project, if you haven’t, created it within your project folder to be simple to be imported from anywhere in the project with the following content:

from smart_rest_client.client import api_client_factory
from smart_rest_client.settings import APIClientSettings

api_client_settings = {
    'API': {
          'NAME': 'test_api',
          'BASE_URL': 'https://example.com',
          'ENDPOINTS': [
              '/v1/order/orders',
              '/v1/user/users',
              ...
          ],
          'AUTHENTICATION_ACCESS_TOKEN': 'TOKEN'
      }
  }


api_settings = APIClientSettings(API_CLIENT_SETTINGS)
api_client = client_factory('test_api', api_settings)
  • Para mais informações sobre as configurações diponiveis, veja em:

3. Métodos Cliente

Para cada endpoint o API Client irá criar a seguinte estrutura:

Exemplo para /user/users/

  • Criar:

usage: smart_rest_client.user.users.create(data=data)
return: Response of POST of data (dict) to /user/users/
  • Listar:

usage: smart_rest_client.user.users.list()
return: Response of GET to /user/users/
  • Get/Recuperar/Detalhe:

usage: smart_rest_client.user.users.get(id=123)
return: Response of GET to /user/users/123/
  • Atualizar:

usage: smart_rest_client.user.users.update(id=123, data=data, partial=False)
return: the response of UPDATE or PATCH of data (dict) to /user/users/123/
  • Deletar:

usage: smart_rest_client.user.users.delete(id=123)
return: Response of GET to /user/users/123/