A python package that simplifies the process of making API requests to 42 Portugal's API.
Project description
pt42api_wrapper
A python package that simplifies the process of making API requests to 42 Portugal's API. With this package, developers can quickly and easily access the API's functionality, without having to deal with the complexities of working directly with it.
How to install
pip install pt42api-wrapper
Making a simple request
- Have a
.env
file that looks like this:
export API_ENDPOINT=''
export AUTH_URL=''
export CLIENT_ID=''
export CLIENT_SECRET=''
export SENTRY_DSN=''
- Use the following code to make a simple request:
import pt42api_wrapper as pt42api
api = pt42api.ApiWrapper()
api.get(url='campus/')
Using in Django Projects
# settings.py
...
PT42API_WRAPPER = {
'base_url': os.environ.get('API_ENDPOINT'),
'auth_url': os.environ.get('AUTH_URL'),
'client_id': os.environ.get('CLIENT_ID'),
'client_secret': os.environ.get('CLIENT_SECRET'),
'sentry_dsn': os.environ.get('SENTRY_DSN')
}
from django.conf import settings
import pt42api_wrapper as pt42api
(...)
api = pt42api.ApiWrapper(**settings.PT42API_WRAPPER)
url = f'{self.request_url}{data.get("id")}/'
response = api.delete(url, data)
return http.JsonResponse(response.json(), status=response.status_code)
(...)
Configure Api log level
from pt42-wrapper import ApiWrapper
(...)
api = ApiWrapper(log_level=logging.DEBUG)
(...)
Running tests
python3 tests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pt42api_wrapper-1.0.6.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file pt42api_wrapper-1.0.6.tar.gz
.
File metadata
- Download URL: pt42api_wrapper-1.0.6.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97b9467aa4ce8dfbb75ec3fbe9e641599d8dd3074298201ac9f4d2dcd14fb456 |
|
MD5 | 42b27ff861297fad18938ad5a9823811 |
|
BLAKE2b-256 | df100db26bbb079211fa1222c3c6ab6f782ac65438bc9aac04e3c09a3e8ad786 |
File details
Details for the file pt42api_wrapper-1.0.6-py3-none-any.whl
.
File metadata
- Download URL: pt42api_wrapper-1.0.6-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | feeb2bdb37f85a1e10e95b73ad8360aca2fbeb12e355c55b0da0dd51f4710ff7 |
|
MD5 | 9790fa6d1527c2b242c0f0cfa54e1285 |
|
BLAKE2b-256 | d6a71b9f0a0363b2aa2e93f585383ec99d9f128269ff419a4c4bfd04f2e638e5 |