Overview

SnAPI is a framework for building restful API clients in Python. Its primary goals are to provide a simple, consistent interface for interacting with restful APIs, and to provide a way to easily extend the framework to support new APIs.

Why SnAPI?

  • Flexible Authentication: Supports various authentication methods easily configurable per request.

  • Asynchronous Support: Built-in support for asynchronous operations making it ideal for I/O bound tasks.

  • Caching Mechanisms: Integrated caching features help reduce latency and load, enhancing performance.

  • Easy Endpoint Management: Simplify the addition and management of various API endpoints.

Sample Usage

from snapi import API

api = API('http://api.example.com/v1')
api.add_endpoint('/users', 'get_users')

# GET /users
output = api.get_users() # or api.request_endpoint(endpoint_name='get_users')
print(output)

SnAPI adds a simple interface for implementing API keys as well. API Keys may be passed through request parameters, headers, or via HTTP auth.

Asynchronous Requests are easily done by toggling async. This is ideal for making many requests at once.

Asynchronous requests with rate limiting. The following will only allow a maximum of 2 connections to the API at once. This defaults to 10.