packge to allow defining an API via dictionaries
Project description
# dappy
package to allow defining an API declaratively
## Example
All the API calls below (".get()", ".search()") return a dict parsed with json.loads()
```python
from dappy import API, Endpoint
ItunesAPI = API('itunes.apple.com', [
Endpoint(
'search', '/search',
query_map={ 'search_string': 'term' }, # Map input query params to what the API actually expects
defaults={ 'entity': 'podcast' } # Default query params to send with every request
),
Endpoint('get', '/lookup')
], scheme='https') # scheme defaults to 'https'
ItunesAPI.search(query={
'search_string': 'Hello, World' # 'search_string" will get mapped to 'term' before we send the request
}) # 'entity=podcast' gets added to the query without us providing it here
ItunesAPI.get(query={ 'id': '656270845' })
```
See https://dappy.readthedocs.io/en/latest/usage.html for more usage info.
* Free software: MIT license
* Documentation: https://dappy.readthedocs.io.
=======
History
=======
2.0.1 (2019-01-03)
------------------
* Readme change to clarify the new API expectations
2.0.0 (Who can remember)
------------------
* API now behaves differently.
* no more kwargs on endpoint calls, use `query={}` to pass query params and `params={}` to pass post params
1.0.0 (2017-09-13)
------------------
* First release on PyPI.
package to allow defining an API declaratively
## Example
All the API calls below (".get()", ".search()") return a dict parsed with json.loads()
```python
from dappy import API, Endpoint
ItunesAPI = API('itunes.apple.com', [
Endpoint(
'search', '/search',
query_map={ 'search_string': 'term' }, # Map input query params to what the API actually expects
defaults={ 'entity': 'podcast' } # Default query params to send with every request
),
Endpoint('get', '/lookup')
], scheme='https') # scheme defaults to 'https'
ItunesAPI.search(query={
'search_string': 'Hello, World' # 'search_string" will get mapped to 'term' before we send the request
}) # 'entity=podcast' gets added to the query without us providing it here
ItunesAPI.get(query={ 'id': '656270845' })
```
See https://dappy.readthedocs.io/en/latest/usage.html for more usage info.
* Free software: MIT license
* Documentation: https://dappy.readthedocs.io.
=======
History
=======
2.0.1 (2019-01-03)
------------------
* Readme change to clarify the new API expectations
2.0.0 (Who can remember)
------------------
* API now behaves differently.
* no more kwargs on endpoint calls, use `query={}` to pass query params and `params={}` to pass post params
1.0.0 (2017-09-13)
------------------
* First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dappy-2.1.0.tar.gz
(14.2 kB
view hashes)
Built Distribution
Close
Hashes for dappy-2.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afc29c900cb7153ce8ea4c2ae73a6fa4bb671b2952700bcba925cbff74ae09cc |
|
MD5 | ef2c1d37b3ae1b06cf156338d796755f |
|
BLAKE2b-256 | cff7e39ba8e9a0320cb21f273d531542cbe2620fdccf5d033c0d31ebc7c6b4ea |