Bearer API client for Python

Overview

Bearer Python

Bearer Python client

Installation

pip install bearer

Usage

Get your Bearer Secret Key and integration id from the Dashboard and use the Bearer client as follows:

Calling any APIs

from bearer import Bearer

bearer = Bearer('BEARER_SECRET_KEY') # find it on https://app.bearer.sh/keys
github = (
    bearer
      .integration('your integration id') # you'll find it on the Bearer dashboard https://app.bearer.sh
      .auth('your auth id') # Create an auth id for your integration via the dashboard
)

print(github.get('/repositories').json())

We use requests internally and we return the response from this library from the request methods (request, get, head, post, put, patch, delete).

More advanced examples:

# With query parameters
print(github.get('/repositories', query={ 'since': 364 }).json())

# With body data
print(github.post('/user/repos', body={ 'name': 'Just setting up my Bearer.sh' }).json())

Setting the request timeout, and other http client settings

Bearer client is written on top of excellent requests library. Bearer provides reasonable defaults but you can adjust http client configuration by using any keyword argument which is accepted by requests.request method using http_client_settings keyword argument. By default bearer client times out after 5 seconds. Bearer allows to increase the timeout to up to 30 seconds

from bearer import Bearer

bearer = Bearer('BEARER_SECRET_KEY', http_client_settings={"timeout": 10}) # increase the request timeout to 10 seconds globally

# you can specify client settings per integration as well
github = bearer.integration('github', http_client_settings={"timeout": 2}) # github api is super fast 2 seconds should be plenty

print(github.get('/user/repos'))

Development

# setup venv
$ python -m venv venv

# install dependencies
$ venv/bin/python setup.py develop

# start the console
$ venv/bin/python
You might also like...
Python Client for Instagram API

This project is not actively maintained. Proceed at your own risk! python-instagram A Python 2/3 client for the Instagram REST and Search APIs Install

A Python Client for News API

newsapi-python A Python client for the News API. License Provided under MIT License by Matt Lisivick. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRAN

SmartFile API Client (Python).
SmartFile API Client (Python).

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software. Summary This library includes two API cli

Python client for the Socrata Open Data API

sodapy sodapy is a python client for the Socrata Open Data API. Installation You can install with pip install sodapy. If you want to install from sour

Python client for the Echo Nest API
Python client for the Echo Nest API

Pyechonest Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web. Pyechonest is an

A Python Tumblr API v2 Client

PyTumblr Installation Install via pip: $ pip install pytumblr Install from source: $ git clone https://github.com/tumblr/pytumblr.git $ cd pytumblr $

A super awesome Twitter API client for Python.

birdy birdy is a super awesome Twitter API client for Python in just a little under 400 LOC. TL;DR Features Future proof dynamic API with full REST an

Cord Python API Client

Cord Python API Client The data programming platform for AI 💻 Features Minimal low-level Python client that allows you to interact with Cord's API Su

Pure Python 3 MTProto API Telegram client library, for bots too!

Telethon ⭐️ Thanks everyone who has starred the project, it means a lot! Telethon is an asyncio Python 3 MTProto library to interact with Telegram's A

Comments
  • Add auth details fetching

    Add auth details fetching

    Adds get_auth method to allow fetching auth details in a user-friendly way.

    Also fixes tests that were using the wrong keyword arg name for asserting request headers.

    opened by didroe 0
  • Logging

    Logging

    Allows to set basic logging for Bearer Python client.

    You can set the logger level using the following syntax (defaults to logging.INFO) :

    import logging
    from bearer import logger
    
    logger.setLevel(logging.DEBUG)
    

    By default each request will produce the following log entry:

    2019-10-16 14:54:27,116 - bearer - INFO - request id: 1-5da71302-a9230375efae6a1b9303c35c
    

    For logging.DEBUG you will get the following log entry

    2019-10-16 14:52:27,507 - bearer - DEBUG - sending request
        url: https://proxy.staging.bearer.sh/postman_echo/get
        method: GET
        params: None
        body: None
        headers: {'Authorization': 'sk_production_Xs3hErAxOajxayx7PD7eT9WamrHRtW6p', 'User-Agent': 'Bearer-Python (2.0.0)'}
        http_client_settings: {'timeout': 5}
    2019-10-16 14:52:28,505 - bearer - INFO - request id: 1-5da7128b-0db046accec92704a18f01f8
    
    opened by RadekMolenda 0
  • Proxy rewrite

    Proxy rewrite

    This is a breaking change

    • Stop using old url and start using proxy url
    • unify the bearer client interface:
      • deprecate integartion_host & timeout
      • prefer using host & http_client_settings
    opened by RadekMolenda 0
  • Reimplement client

    Reimplement client

    Reimplements the client for parity with libs in other languages.

    from bearer import Bearer
    
    bearer = Bearer('<apiKey>')
    
    # Invoke a function using OAuth
    bearer.invoke('<buid>', '<functionName>', params={ 'authId': '<authId>' })
    
    # For a function using Basic/API Key auth
    bearer.invoke('<buid>', '<functionName>', params={ 'setupId': '<setupId>' })
    
    opened by didroe 0
Releases(release-v3.1.0)
Owner
Bearer
Automate data security risk assessment for cloud-native applications.
Bearer
Python API Client for Twitter API v2

?? Python Client For Twitter API v2 ?? Why Twitter Stream ? Twitter-Stream.py a python API client for Twitter API v2 now supports FilteredStream, Samp

Twitivity 31 Nov 19, 2022
Dns-Client-Server - Dns Client Server For Python

Dns-client-server DNS Server: supporting all types of queries and replies. Shoul

Nishant Badgujar 1 Feb 15, 2022
Raphtory-client - The python client for the Raphtory project

Raphtory Client This is the python client for the Raphtory project Install via p

Raphtory 5 Apr 28, 2022
Drcom-pt-client - Drcom Pt version client with refresh timer

drcom-pt-client Drcom Pt version client with refresh timer Dr.com Pt版本客户端 可用于网页认

null 4 Nov 16, 2022
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

MonkeyLearn 157 Nov 22, 2022
🖥️ Python - P1 Monitor API Asynchronous Python Client

??️ Asynchronous Python client for the P1 Monitor

Klaas Schoute 9 Dec 12, 2022
Python API Client for Close

Close API A convenient Python wrapper for the Close API. API docs: http://developer.close.com Support: [email protected] Installation pip install clos

Close 56 Nov 30, 2022
Python client for CoinPayments API

pyCoinPayments - Python API client for CoinPayments Updates This library has now been converted to work with python3 This is an unofficial client for

James 27 Sep 21, 2022
DEPRECATED - Official Python Client for the Discogs API

⚠️ DEPRECATED This repository is no longer maintained. You can still use a REST client like Requests or other third-party Python library to access the

Discogs 483 Dec 31, 2022
The Foursquare API client for Python

foursquare Python client for the foursquare API. Philosophy: Map foursquare's endpoints one-to-one Clean, simple, Pythonic calls Only handle raw data,

Mike Lewis 400 Dec 19, 2022