Skip to content

Repository files navigation

nap

api access models and tools

Accessing APIs open-endily is an easy affair. pip install requests, pass in your data get data back. But the slight differences and demands of different API creating code that’s structured, re-usable and simple proves difficult.

nap hopes to help.

# note/client.pyfromnap.resourcesimportResourceModel, FieldclassNote(ResourceModel):
pk=Field(api_name='id', resource_id=True)
title=Field()
content=Field()
classMeta:
root_url='http://127.0.0.1:8000/api/'resource_name='note'n=Note(title='Some Title', content="some content")
# POST http://127.0.0.1:8000/api/note/n.save()
n=Note.get('note/1/')
# Some Titlen.title# GET http://127.0.0.1:8000/api/note/1/n=Note.objects.lookup(pk=1)
n.title="New Title"n.content="I sure do love naps!"# PUT http://127.0.0.1:8000/api/note/1/n.save()
n=Note.objects.get('note/1/')
# "New Title"n.title

nap aims to:

  • Support Read (GET) and Write (POST/PUT/PATCH)
  • Required little to no configuration needed for to-spec REST APIs
  • Be easily configurable to fit any REST-like API
  • Be customizable to fit even edgier use cases

Docs

https://nap.readthedocs.org

Installation

% pip install git+https://github.com/jacobb/nap/

About

api access modeling and tools

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages