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_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


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

Uploaded Source

Built Distribution

pt42api_wrapper-1.0.4-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pt42api_wrapper-1.0.4.tar.gz
Algorithm Hash digest
SHA256 3b9264531d33a75b9fbafa9d2f34d2c1c64a856362cea4987816bd37776a9c73
MD5 78fd3b1261880340d919c0d33fbfee3f
BLAKE2b-256 33840970a0e090e3e777534e1d1b93f108ebe01e55df3c5391a34085b1c24839

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pt42api_wrapper-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6ea07d2281feafd9e7b39551f396ee1776155e645f9ae3d7553aa1cc9c3bc873
MD5 4036d02568408f6dc65ff5a593cbf2be
BLAKE2b-256 325a8b9b37c885bf2793fef31cb32792c01ba7bde16b4327062e31ce5be8a1c9

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