WEB HTTP API MAPPER 

django-wham

REST APIs disguised as Django Models



@mbylstra

Art Processors

https://github.com/mbylstra/django-wham

getting an artist from a few similar APIs

#spotify
https://api.spotify.com/v1/artists/52341
#last.fm
http://ws.audioscrobbler.com/2.0?method=artist.getinfo&mbid=52341&api_key=a04961fe4330211ff149a949dfabef51&format=json
#deezer
http://api.deezer.com/artist/52341
 


maybe you could just do this?

Artist.objects.get(id="0LcJLqbBmaGUft1e9Mm8HV")


With django-wham you can use REST APIs as though they were Django Models

regular django query:

TwitterUser.objects.get(screen_name="melbdjango").tweets.all()

django-wham query:

TwitterUser.objects.get(screen_name="melbdjango").tweets.all()


The only difference is that django-wham gets the results
from a remote REST API, rather than from a database.

This url is requested behind the scenes:

  GET https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=djangowham

Web Http Api to Object Relational Mapper Mapper

Web Http Api to Object Relational Mapper Mapper


ORM
SQL
WEB


sometimes Web APIs don't have 

all the methods you would like



...but django-wham can do any query the Django ORM can do


TwitterUser.objects.get(screen_name='DjangoConAU').tweets.all().order_by('-retweet_count') 

because it inherits from django.db.models.Model

class Tweet(WhamModel):
    id = WhamCharField(max_length=100, primary_key=True)
    text = WhamTextField() 
class WhamModel(models.Model):
    objects = WhamManager() 

 

*** live demo ***

django-wham

By Michael

django-wham

  • 2,395