RestMapper takes the pain out of integrating with RESTful APIs.

Overview

python-restmapper

CI Status Version

RestMapper takes the pain out of integrating with RESTful APIs. It removes all of the complexity with writing API-specific code, and lets you focus all your energy on the important stuff. Here's a quick example (using Twitter):

Twitter = RestMapper("https://api.twitter.com/1.1/{path}.json")
auth = OAuth1('YOUR_APP_KEY', 'YOUR_APP_SECRET', 'USER_OAUTH_TOKEN', 'USER_OAUTH_TOKEN_SECRET')
twitter = Twitter(auth=auth)
response = twitter.statuses.mentions_timeline()

Whoa, easy, right? This will call https://api.twitter.com/1.1/statuses/mentions_timeline.json, authenticate the request using OAuth1, and return the response as JSON. The great thing is that there's not much else you need to learn to integrate with any other API. You just plug in the base URL format, provide any optional authentication handlers (that requests provides), and then just start making API calls.

See requests-cloudkit for an example of an authentication handler working with Apple's CloudKit which is compatible right out of the box with RestMapper.

Installation

RestMapper is available for download through the Python Package Index (PyPi). You can install it right away using pip or easy_install.

pip install restmapper

Usage

The first thing you need to do is generate a base RestMapper object that will allow you to instantiate a connection with a remote API.

>>> Twitter = RestMapper("https://api.twitter.com/1.1/{path}.json")

{path} is just a placeholder for the rest of the path. You'll specify this later when making API calls.

Twitter's API is protected by OAuth1, so the next step is to provide authentication. When integrating with any other API, any requests-compatible auth object can be provided.

>>> from requests_oauthlib import OAuth1
>>> auth = OAuth1('YOUR_APP_KEY', 'YOUR_APP_SECRET', 'USER_OAUTH_TOKEN', 'USER_OAUTH_TOKEN_SECRET')
>>> twitter = Twitter(auth=auth)

Now you can start making calls. The API object's attributes and properties map one-to-one with the API you're integrating with. E.g., the below:

>>> response = twitter.statuses.mentions_timeline()

...will request https://api.twitter.com/1.1/statuses/mentions_timeline.json. The path implied by the attribute syntax is inserted right where the path placeholder is in the Twitter object's instantiation earlier.

If you want to pass in body data for a POST, provide a single argument to the call to the API, and specify "POST" as the first attribute. I.e.

>>> twitter.POST.my.request(data)

PATCH, PUT, GET, and POST are all supported. GET is currently the default.

Miscellaneous

By default, python-restmapper will return parsed JSON objects. If you'd like the raw response object for a request, just pass in parse_response=False as an argument to the API object.

Support

If you like this library, or need help implementing it, send us an email: [email protected].

License License

Apache License, Version 2.0. See LICENSE for details.

Owner
Lionheart Software
Lionheart Software
A dog facts python module

A dog facts python module

Fayas Noushad 3 Nov 28, 2021
Python library for datamining glitch information from Gen 1 Pokémon GameBoy ROMs

g1utils This is a Python library for datamining information about various glitches (glitch Pokémon, glitch maps, etc.) from Gen 1 Pokémon ROMs. TODO A

1 Jan 13, 2022
Dyson Sphere Program Blueprint Toolkit

dspbptk This is dspbptk, the Dyson Sphere Program Blueprint toolkit. Dyson Sphere Program is an amazing factory-building game by the incredibly talent

Johannes Bauer 22 Nov 15, 2022
SymbLang are my programming language! Insired by the brainf**k.

SymbLang . - output as Unicode. , - input. ; - clear data. & - character that the main line start with. @value: 0 - 9 - character that the function

1 Apr 04, 2022
Problem statements on System Design and Software Architecture as part of Arpit's System Design Masterclass

Problem statements on System Design and Software Architecture as part of Arpit's System Design Masterclass

Relog 1.1k Jan 04, 2023
Python dictionaries with advanced dot notation access

from box import Box movie_box = Box({ "Robin Hood: Men in Tights": { "imdb stars": 6.7, "length": 104 } }) movie_box.Robin_Hood_Men_in_Tights.imdb_s

Chris Griffith 2.1k Dec 28, 2022
RangDev Notepad App With Python

RangDev Notepad-App-With-Python Take down quick and speedy notes! This is a small project of a notepad app built with Tkinter and SQLite3. Database cr

rangga.alrasya 1 Dec 01, 2021
Cross-platform MachO/ObjC Static binary analysis tool & library. class-dump + otool + lipo + more

ktool Static Mach-O binary metadata analysis tool / information dumper pip3 install k2l Development is currently taking place on the @python3.10 branc

Kritanta 301 Dec 28, 2022
Github dorking tool

gh-dork Supply a list of dorks and, optionally, one of the following: a user (-u) a file with a list of users (-uf) an organization (-org) a file with

Molly White 119 Dec 21, 2022
python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Enyi 1 Jan 05, 2022
Python 3.9.4 Graphics and Compute Shader Framework and Primitives with no external module dependencies

pyshader Python 3.9.4 Graphics and Compute Shader Framework and Primitives with no external module dependencies Fully programmable shader model (even

Alastair Cota 1 Jan 11, 2022
A rough GSL work DynSAGE of my graduation project

DynSAGE Codes w.r.t DynSAGE-Diffuse can be found in function apply_dyn_model_v2 of src/utils.py. The training entrance is Line 144 - 155 of src/main.p

Yuhan Wang 3 Mar 22, 2022
Refer'd Resume Scanner

Refer'd Resume Scanner I wanted to share a free resource we built to assist applicants with resume building. Our resume scanner identifies potential s

Refer'd 74 Mar 07, 2022
Set of tools to analyze Tinynuke samples

tinynuke-toolset You'll find in that repository a set of tools and scripts I developped to analyze Tinynuke samples. Dll extractor: script used to ext

Heat Miser 14 Aug 18, 2022
A simple PID tuner and simulator.

PIDtuner-V0.1 PlantPy PID tuner version 0.1 Features Supports first order and ramp process models. Supports Proportional action on PV or error or a sp

3 Jun 23, 2022
Python wrapper to different clients to determine how a particular term is used.

Python wrapper to different clients to determine how a particular term is used.

Chris Mungall 3 Oct 24, 2022
Brython (Browser Python) is an implementation of Python 3 running in the browser

brython Brython (Browser Python) is an implementation of Python 3 running in the browser, with an interface to the DOM elements and events. Here is a

5.9k Jan 02, 2023
Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

Prophet is a tool to discover resources detailed for cloud migration, cloud backup and disaster recovery

22 May 31, 2022
Store Simulation

Almacenes Para clonar el Repositorio: Vaya a la terminal de Linux o Mac, o a la cmd en Windows y ejecute:

Johan Posada 1 Nov 12, 2021
A discord group chat creator just made it because i saw people selling this stuff for like up to 40 bucks

gccreator some discord group chat tools just made it because i saw people selling this stuff for like up to 40 bucks (im currently working on a faster

baum1810 6 Oct 03, 2022