oppy (python API)

sozin
sozin
edited February 2011 in API Discussion
I've created the skeleton of a python implementation of the obsidian portal API named "oppy".

Here's the github url: https://github.com/lhayhurst/oppy

As per the README, right now it is -very- simple: it comes with a bootstrapping program that will walk the user through the creation of their consumer key, consumer secret, oauth token, and oauth secret. The README describes how to download it, its dependencies, and run it to register your application on OP.

Stay tuned for code that actually does something with the API :-)

Comments

  • sozin
    sozin
    Posts: 20
    >>Stay tuned for code that actually does something with the API :-)
    The easiest one is out- the user API. Usage is pretty trivial:

    userApi = UserAPI( OpyConfig() ) #assumes that you've already bootstrapped your oauth key and tokens using bootstrap.py
    userApi.fetch() #fetches the user info as per http://help.obsidianportal.com/kb/api/api-users
    print userApi.username(); #prints your username
    print userApi.campaigns(); #returns a list of campaigns
    #etc
  • sozin
    sozin
    Posts: 20
    Campaign API is implemented.
  • sozin
    sozin
    Posts: 20 edited February 2011
    user and campaign api code basically done. to give it a test wrote I wrote a simple graph traversal script to walk through the user-campaign graph (starting with user='micah') and graph it out visually.

    micah's graph: https://github.com/lhayhurst/oppy/blob/master/examples/micah.gif (click raw in github to see it full size)
    https://github.com/lhayhurst/oppy/raw/master/examples/sozin.gif (sozin's graph)
    src code: https://github.com/lhayhurst/oppy/blob/master/examples/graph.py
    Post edited by sozin on
  • Micah
    Micah
    Posts: 894
    Looks great! I'm glad you were able to get going with OAuth so quickly. Many people have had a lot of problems, but it seems like you were able to breeze through. Are the Python OAuth libraries really easy to use?
  • sozin
    sozin
    Posts: 20
    Yeah, the python oauth2 library is quite straightforward. Most of the time was spent reading the oauth documentation, which is ... voluminous!
  • Micah
    Micah
    Posts: 894
    I would bet that most people's graphs have the same strongly connected attribute where their close gaming group clusters around the same campaigns.

    When I first started, I imagined Obsidian Portal as partly a social-network. Only after a while did I realize that the network was in fact a collection of isolated islands. Your "network" rarely extends past the group that you game with. It's not a bad thing, just different from other "friend-collector" social networks.

    Cool tool :)
  • sozin
    sozin
    Posts: 20
    yeah, the island effect is definitely visible on the two graphs I built.

    if I had all of the user ids (or user names), I could kick off a job to build the graph of the entire system. Would probably confirm the island effect. (as well as look neat.)
  • Micah
    Micah
    Posts: 894
    Take it easy for now...the API isn't exactly optimized, and firing off the 100s of 1000s of calls needed to build the graph could cause problems. We may have to institute rate limits at some point to prevent DDOS attacks or runaway apps causing system slowdown.
  • sozin
    sozin
    Posts: 20
    Heh, sure thing :-) Sounds like a good sustained load test of the system, so whenever you're ready to push it, let me know. The graph script is sequential, so it'll just create steady load, but it wouldn't be too tough to thread out the different user-campaign requests to create a parallel pounding.
  • sozin
    sozin
    Posts: 20
    Oppy now supports the following:

    - Simple object oriented API
    - Easy to use bootstrapping utility to set up your oauth consumer key, consumer secret, oauth token and oauth secret.
    - Ability to fetch a campaign by campaign id or slug
    - Ability to fetch a user by self, by id, or by username
    - Ability to fetch all the characters for a given campaign, a character by id, or a character by slug
    - Ability to fetch a wiki by campaign, by campaign/page id, and by campaign/page slug.
    - Ability to fetch the campaign's adventure log.
    - Fully integration tested

    Note that there are two outstanding bugs, both seemingly on Obsidian Portal:

    - Fetching a character by slug might return the wrong character, if there is another character with that slug
    - Fetching a wiki page by slug returns the wrong page.

    At this point oppy should be at feature parity with both mage-hand and sunrod. (Hey, Micah, any chance you can throw oppy up onto http://help.obsidianportal.com/kb/api/api-libraries?)

    On the backlog:

    - Ability to create and update a character
    - Ability to create an update a wiki page
    - Ability to get, show, update, and submit dynamic sheet templates.

    Once these 3 features are done I'll have fully rounded out the public API.

    --sozin
  • sozin
    sozin
    Posts: 20
    >> (Hey, Micah, any chance you can throw oppy up onto http://help.obsidianportal.com/kb/api/api-libraries?)

    *gentle bump*
  • MichaelHoyle
    Posts: 3
    hey, is this still maintained / any chance it will become "official"?

    If it's not good enough to be "official", what needs to be done to make it good enough?

    szoin: if you're not maintaining this anymore, are you open to handing it off to someone?
  • sozin
    sozin
    Posts: 20
    hey there.

    - I haven't changed the code in a long time
    - w/respect to making it official, I don't know the answer to that one. I could be wrong, but it seems like OP management stopped paying attention to the API threads (like this one), and my gaming groups moved off of Obsidian Portal, so I stopped working on the code. my OP account has expired as well, so I can't run the unit tests, but if you have a current OP account you can try running all the unit tests to see if the back end server code still supports the same API that I coded against.
    - I'd be happy to hand over ownership of the project! just let me know how you'd like to proceed and I'd be happy to help out.

    cheers
  • MichaelHoyle
    Posts: 3
    I spun up an OP API account yesterday, but I wasn't able to run the unit tests - something's weird with python-oauth2, so I'll have to figure that out before I proceed.

    Regarding ownership handover, I'd like to read through your code in depth before we actually think about doing that. If I'm happy with it, or i feel like it would save me a lot of time to refactor it into working, I figure you can just transfer ownership of the github repo to me. As long as there isn't anything else related to the project that would need to be handed off, that's probably all we'd need to do.

    I'll try to get through the code today or tomorrow and let you know my thoughts then. if you'd prefer another method of communication about this, let me know - these forums probably aren't the best avenue available to us.

    Thanks!
  • sozin
    sozin
    Posts: 20
    Cool. feel free to reach out directly to me at sozinsky at gmail dot com
Sign In or Register to comment.

March 2024
Wrath of the Highborn

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions