HAF Plug & Play: Delegations API

in HiveDevslast year

Delegations-API.png


@imwatsi shares an update on the development of 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.

Sort:  

New to hive and sounds really cool, Im very familiar with docker (no dev), looks very simple to deploy, any other features in mind like extract curation data?

Welcome to Hive. Glad you find the setup easy to work with. What kind of curation data are you interested in?

I don't know if this is possible, but if it is, it would be helpful if you can add an endpoint for HIVE transfers to the DHF and the resulting HBD. When HIVE is sent to the DHF, it is immediately converted to HBD. However, a virtual operation to track how much HBD it was converted to was added only on 2022-10-11 (see this). So from 2022-10-11 onwards, we know how much HBD was added to the DHF, but we don't know for before that. With the HAF data you have available, would it be possible to get the amount of HBD that each HIVE transfer was converted for?

This will help the Hive Open Stats project. We're working on adding stats to track the DHF balance and incoming/outgoing funds.

Interesting... I will look into it.

the truth that you cut "delegations" to "deleg" triggered me a lot. :D

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below

Lol, I hear you :)

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below

Congratulations @freebeings! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 1250 upvotes.
Your next target is to reach 1500 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Feedback from the February Hive Power Up Day
Hive Power Up Month Challenge - January 2023 Winners List
Be ready for the February edition of the Hive Power Up Month!
The Hive Gamification Proposal
Support the HiveBuzz project. Vote for our proposal!