Web: Python3 Gitcoin API Client

Created on 19 May 2018  ·  20Comments  ·  Source: gitcoinco/web

Add an API function to the Gitcoin Python SDK.

Why Is this Needed?

Easier Gitcoin API consumption, both internally, and by third parties.

Supported Features

  • Ability to receive bounties from the gitcoin API
  • Ability to filter by all of the filters available in the API
  • Support for sorting and pagination
  • Readme which documents usage
  • Supports python 3.x

Proposed Usage

pip install gitcoin
from gitcoin import Gitcoin
api = Gitcoin()
api.bounties.all()
api.filter(pk__gt=100).all()

API

public (unrestricted)

GET /api/v2/bounties

private (restricted)

Bounty

Please create a PR against the following repo https://github.com/gitcoinco/python-api-client

in review

Most helpful comment

Hello @mbeacom , @owocki (and @gitcoinbot ;-) ,

Please review https://github.com/gitcoinco/python-api-client/pull/3 .

I will submit this now on the bounty page but would be happy about any kind of feedback!

Phew, my first bounty ever is shaping up to become an actual thing, wow! This was quite the revealing learning experience!

Thank you!
Raphael

All 20 comments

@mbeacom look ok?

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This issue now has a funding of 0.12 ETH (82.55 USD @ $687.95/ETH) attached to it.__

Made a few minor adjustments to the proposed usage. lgtm!

Hi there, I'm researching a bit on this and looking over the repo for the first time -- is the api currently
/api/v0.1/bounties? Thanks!

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work has been started__.

These users each claimed they can complete the work by 8 months, 3 weeks ago.
Please review their action plans below:

1) raphaelhuefner has started work.

Hello Kevin,

Questions:

  • "Ability to receive bounties from the gitcoin API" means that the API client should only wrap /api/v0.1/bounties and /api/v0.1/bounties/ , and NONE of the other URLs starting with /api/v0.1/* ? (As defined at https://github.com/gitcoinco/web/blob/master/app/app/urls.py#L53-L57 .) Is that correct?
  • In "Proposed Usage", is there a chance that the line api.filter(pk__gt=100).all() should rather read api.bounties.filter(pk__gt=100).all() ?

Action plan:

  • Extract the complete set of possible query params from https://github.com/gitcoinco/web/blob/master/app/dashboard/router.py#L132-L176
  • Expose those query params as keyword arguments in filter()
  • Expose orderby param as orderby()
  • Expose limit and offset params as page_size() and get_page(pagenum=1)
  • Fire urllib.request.urlopen() in all() and get_page()
  • Expose result set as iterator

Cheers!
Raphael

Learn more on the Gitcoin Issue Details page.

  1. yes thats right
  2. the former seems simpler to me but i dont feel strongly about it. @mbeacom any feedback?

@raphaelhuefner

Questions:

  1. For the scope of this bounty, I think bounties is it. Ultimately, we'll probably want to expand this to include universe as well.
  1. I think api.bounties works best, so we can ultimately work in universe and other api operations.

Please see my proposed base example at:
https://github.com/gitcoinco/python-api-client/pull/1/files#diff-04c6e90faac2675aa89e2176d2eec7d8R16

Action Plan:

Can we:

  • Use order_by vs orderby to maintain parity with django ?
  • Setup get_page() to take page number and limit?
  • Use requests versus urllib

Feel free to ping me on slack if you have any questions!

@mbeacom Thank you for your feedback!

I'll take your PR into account.

I have all of these 3 going:

  • order_by() with an _
  • get_page(number, per_page)
  • using requests library

@mbeacom @gitcoinbot Please use this PR to give some feedback for further direction: https://github.com/gitcoinco/python-api-client/pull/2

Thank you!
Raphael

@raphaelhuefner Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] warning (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Hello @mbeacom , @owocki (and @gitcoinbot ;-) ,

Please review https://github.com/gitcoinco/python-api-client/pull/3 .

I will submit this now on the bounty page but would be happy about any kind of feedback!

Phew, my first bounty ever is shaping up to become an actual thing, wow! This was quite the revealing learning experience!

Thank you!
Raphael

Alas, this is also my first (payable) interaction with Ethereum, so I had to apply for the Gitcoin faucet in order to go through with submitting this work on the bounty page. (Just in case you wondered why nothing is submitted there, yet.)

Phew, my first bounty ever is shaping up to become an actual thing, wow! This was quite the revealing learning experience!

hehe... welcome to the other side!

Alas, this is also my first (payable) interaction with Ethereum, so I had to apply for the Gitcoin faucet in order to go through with submitting this work on the bounty page. (Just in case you wondered why nothing is submitted there, yet.)

thanks! im on calls all day today so can't review the PR today but i did just approve your faucet request

@raphaelhuefner Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] warning (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@raphaelhuefner @owocki @mbeacom Snoozed Gitcoin Bot here as this one is on our side to review 👍

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work for 0.12 ETH (62.14 USD @ $517.84/ETH) has been submitted by__:

  1. @raphaelhuefner

@owocki please take a look at the submitted work:

  • PR by @raphaelhuefner

@mbeacom Thank you for merging my PR https://github.com/gitcoinco/python-api-client/pull/3 !

@owocki Does that merge mean that my work could get accepted on the Gitcoin issue page ?

I wasn't even sure myself anymore, but I actually managed to submit my work before the expiry of the bounty:

fulfillment_submitted_on: 2018-06-11T18:12:52.960243Z
expires_date:             2018-06-17T23:04:02Z

(

Which I looked up with Gitcoin's shiny new Python API client 😄 like so:

from gitcoin import Gitcoin
api = Gitcoin()
bounties = api.bounties.filter(standard_bounties_id=467).filter(pk__gt=3563).all()  # .get(pk) goes 500 at the moment of this writing 
print('fulfillment_submitted_on: {}'.format(bounties[0]['fulfillment_submitted_on']))
print('expires_date:             {}'.format(bounties[0]['expires_date']))

)

Good thing that Gitcoin has a Python API client now 😉 !

yes i'm accepting it today.. weee!

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__The funding of 0.12 ETH (34.66 USD @ $288.86/ETH) attached to this issue has been approved & issued to @raphaelhuefner.__

Cool, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IgorPerikov picture IgorPerikov  ·  3Comments

wizzfile picture wizzfile  ·  3Comments

thelostone-mc picture thelostone-mc  ·  4Comments

NukeManDan picture NukeManDan  ·  3Comments

christianbundy picture christianbundy  ·  3Comments