[](https://travis-ci.com/venuebook/mappedapi)
A python library for an easily mapped RESTful API.
**Installation:**
(unless performing a system wide install, it's recommended to install inside of a virtualenv)
```bash
# Install dependencies:
pip install -r requirements.txt # Install core & tests
pip install -r requirements/core.txt # Just install core dependencies
pip install -r requirements/tests.txt # Install test dependencies
# Install mappedapi
python setup.py install
```
**Usage:**
```python
## example/__init__.py
## example/mapping.py
RESOURCE_MAPPING = {
'dogs': {
{'shibes':
'get': {
# https://www.example.com/api/3/dogs/{dog_id}/shibes
'endpoint_base': ['dogs', 'shibes'],
'endpoint_ids': ['dog_id'],
'verb': 'get',
},
'post': {
# https://www.example.com/api/3/dogs/{dog_id}/shibes
'endpoint_base': ['dogs', 'shibes'],
'endpoint_ids': ['dog_id'],
'required_args': ['name'],
'verb': 'post',
},
},
},
}
## example/client.py
import mappedapi.base
from example import mapping
from example.api import APIResource
class Client(object):
RESOURCE_CLASS = APIResource
RESOURCE_MAPPING = mapping.RESOURCE_MAPPING
def __init__(self, access_token):
super(Client, self).__init__()
self.auth = {'token': access_token}
## example/settings.py
API_BASE_URL = 'https://www.example.com/api/'
API_VERSION = '3'
## example/api.py
import mappedapi.base
from example import settings
class APIResource(mappedapi.base.APIResourceItem):
"""Item in a APIResource - Either a nested resource or an action."""
def _get_base_url(self):
return '%s/%s' % (settings.API_BASE_URL, settings.API_VERSION)
def _get_headers(self):
return {
'Authorization': 'Bearer %s' % self.auth['token'],
}
def _process_call_arguments(self, kwargs):
if 'operations' in kwargs:
data = []
for operation in kwargs['operations']:
data.append({'operation': operation[0], 'property': operation[1], 'value': operation[2]})
kwargs['data'] = data
return kwargs
## run.py
import uuid
from example.client import Client
# Initialize the client.
client = Client(YOUR_ACCESS_TOKEN)
print(client.dogs.shibes.get(dog_id='10203').json())
client.dogs.shibes.post(dog_id='10203', data={'name':'Doctor Wow'})
```
**Tests:**
```
py.test mappedapi --cov=mappedapi
```
**Dependencies:**
Core library depends on ``requests``.
Tests depend on ``pytest, pytest-cov, responses``.
Metadata
Release files for MappedAPI 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| MappedAPI-1.0.0.tar.gz | 5.2 kB | Without provenance | Details for MappedAPI-1.0.0.tar.gz |
Release files / MappedAPI-1.0.0.tar.gz
| Download URL | MappedAPI-1.0.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32f585ec233d37ffc473ed16216926a91321dc0ffb19507c0f474a7768a7ce1f
|
|
BLAKE2b-256 checksum How to use checksums |
8d78f12b4d4ea2655f7ef2bf90ba0ff7e1ded6580cebcd2f30694f5acd9898c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for MappedAPI 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.