HAF Plug & Play: Delegations API

@freebeings · 2023-02-02 17:40 · HiveDevs

Delegations-API.png


@imwatsi shares an update on the development of HAF Plug & Play

  • GitHub: https://github.com/FreeBeings-io/haf-plug-play

What’s new?

As requested on GitLab, I have added a new plug to Plug & Play, that brings endpoints for vesting delegations. This complements the current API condenser_api.get_vesting_delegations, which only returns outgoing delegations. Now you can get data about incoming delegations, plus historical delegation data, both incoming and outgoing, for a specified account.


I have deployed the API here: https://deleg.hpp.freebeings.io


Anyone can run a server with the same API by installing HAF Plug & Play and running the service with the deleg plug enabled. I will post a detailed tutorial shortly on how to use Plug & Play to run available plugs and also how to write code to add new plugs that process specific Hive operations.

Endpoints

The following endpoints are avaialble on the server.

/api/deleg/account

This returns a summary of vesting delegation balances for an account, incoming and outgoing, at the time of request.

It takes one parameter: account; which is the name of the Hive account you want to lookup.

Example request:

curl -X 'GET' \
  'https://deleg.hpp.freebeings.io/api/deleg/account?account=imwatsi' \
  -H 'accept: application/json'

Or

https://deleg.hpp.freebeings.io/api/deleg/account?account=imwatsi

Example response body:

{
  "account": "imwatsi",
  "balances": {
    "in": 0,
    "out": 303499.927927
  }
}

/api/deleg/in

Get a list of delegations that are currently given to an account.

Paramaters:

  • account
  • limit

Example request:

curl -X 'GET' \
  'https://deleg.hpp.freebeings.io/api/deleg/in?account=imwatsi.test&limit=100' \
  -H 'accept: application/json'

Or

https://deleg.hpp.freebeings.io/api/deleg/in?account=imwatsi.test&limit=100

Example response body:

[
  {
    "id": 1261821,
    "delegator": "imwatsi",
    "amount": 39451.307672
  }
]

/api/deleg/out

Get a list of outgoing delegations from an account.

Paramaters:

  • account
  • limit

Example request:

curl -X 'GET' \
  'https://deleg.hpp.freebeings.io/api/deleg/out?account=imwatsi&limit=100' \
  -H 'accept: application/json'

Or

https://deleg.hpp.freebeings.io/api/deleg/out?account=imwatsi&limit=100

Example response body:

[
  {
    "id": 1261821,
    "delegator": "imwatsi.test",
    "amount": 39451.307672
  },
  {
    "id": 1311023,
    "delegator": "billz-00",
    "amount": 9664.017574
  },
  {
    "id": 1335826,
    "delegator": "hichem.test",
    "amount": 18908.004815
  }
  ...
]

/api/deleg/history/in

Get a list of historical incoming delegations to an account.

Paramaters:

  • account
  • limit: default 100
  • descending: default true

Example request:

curl -X 'GET' \
  'https://deleg.hpp.freebeings.io/api/deleg/history/in?account=imwatsi&limit=100&descending=true' \
  -H 'accept: application/json'

Or

https://deleg.hpp.freebeings.io/api/deleg/history/in?account=imwatsi&limit=100&descending=true

Example response body:

[
  {
    "id": 8435728,
    "created": "2022-08-19T21:46:48",
    "delegator": "blocktrades.com",
    "amount": 160335.403108
  },
  {
    "id": 8435518,
    "created": "2022-08-19T19:36:36",
    "delegator": "blocktrades.com",
    "amount": 500870.91407
  },
  ...
]

/api/deleg/history/out

Get a list of historical outgoing delegations to an account.

Paramaters:

  • account
  • limit: default 100
  • descending: default true

Example request:

curl -X 'GET' \
  'https://deleg.hpp.freebeings.io/api/deleg/history/out?account=imwatsi&limit=100&descending=true' \
  -H 'accept: application/json'

Or

https://deleg.hpp.freebeings.io/api/deleg/history/out?account=imwatsi&limit=100&descending=true

Example response body:

[
  {
    "id": 8547257,
    "created": "2022-08-23T12:20:00",
    "delegator": "nicolemokhethi",
    "amount": 30000
  },
  {
    "id": 8286482,
    "created": "2022-07-02T15:12:33",
    "delegator": "freebeings",
    "amount": 54695.297887
  },
  {
    "id": 7850258,
    "created": "2022-04-24T16:36:45",
    "delegator": "squigglez",
    "amount": 30000
  },
  ...
]

What's next?

Since it is a new release, I will wait for community feedback to determine what new features/modifications I should work on. Feel free to test it out and give feedback.


by @imwatsi - Co-Founder | CEO | Blockchain Developer of FreeBeings.io LLC


Vote for our witness

Witness Name: @imwatsi

Witness-2.png


We're glad to be building on Hive. Follow the @freebeings account for more updates.

#freebeings-io #haf #development
Payout: 0.000 HBD
Votes: 274
More interactions (upvote, reblog, reply) coming soon.