Skip to main content

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_BASE_URL=''
export API_AUTH_URL=''
export API_CLIENT_ID=''
export API_CLIENT_SECRET=''
  • 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_BASE_URL'),
    'auth_url': os.environ.get('API_AUTH_URL'),
    'client_id': os.environ.get('API_CLIENT_ID'),
    'client_secret': os.environ.get('API_CLIENT_SECRET'),
}
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


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.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

pt42api_wrapper-1.0.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pt42api_wrapper-1.0.0.tar.gz.

File metadata

  • Download URL: pt42api_wrapper-1.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for pt42api_wrapper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0e68cfea7ad191e8477184bcd4e9f62155230fa757290ddf5e3024b0eb9714c4
MD5 7986ff18d9b51e13f1ca9a1320c00eee
BLAKE2b-256 de6c27b29eb0be38e5a6eaa0f3bee24045411c2aefb7ec27a14b2c3ccbfd3e2b

See more details on using hashes here.

File details

Details for the file pt42api_wrapper-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pt42api_wrapper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28be3e36e3e14cb035ef7be2282b33a7b7fe4b91c523883dac8a5a24e8c1d03f
MD5 472edbb794167be3757b706c09558d5c
BLAKE2b-256 e076a0bad603cc6f046b8c749ffbd88b9f878b98d05664017b5f9e3d142599db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page