Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to query the data with pool name or ticker not just pool ID. #103

Closed
lucifer911 opened this issue Dec 29, 2022 · 4 comments
Closed

Comments

@lucifer911
Copy link

Is your feature request related to a problem? Please describe.
Request

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
I am not a Dev, trying to learn it.

Additional context

"Hello, thank you for your API. I am seeking support for the following API call:

curl -X POST "https://api.koios.rest/api/v0/pool_metadata"
-H "Accept: application/json"
-H "Content-Type: application/json"
-d '{"_pool_bech32_ids":["pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp"]}'

I need to know the pool bech32 ID in order to make the above curl request. Is it possible to use the pool name or ticker instead of the pool ID?"

THANK YOU.

@rdlrt
Copy link

rdlrt commented Dec 29, 2022

Unfortunately pool ticker does not provide a unique mapping, as multiple pools can share same ticker. Also, being off-chain - there are a small section of pools that may not resolve (as of smash/dbsync 13.0.5 - this is already fixed in 13.1.0, just not marked as a release from tag yet)
However, for most pools - you can use something like below to fetch the pool ID:

curl -s "https://api.koios.rest/api/v0/pool_list?ticker=eq.JFLD" | jq -r .[0].pool_id_bech32

# pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp

@lucifer911
Copy link
Author

Thank you for the quick response.

@edridudi
Copy link
Collaborator

The same can be achieved using the Java library by the following code:

Options options = Options.builder().option(Filter.of("ticker", FilterType.EQ, "JFLD")).build();
Result<List<Pool>> poolListResult = poolService.getPoolList(options);
Assertions.assertTrue(poolListResult.isSuccessful());
Assertions.assertNotNull(poolListResult.getValue());
log.info(poolListResult.getValue().toString());

Result<List<PoolMetadata>> metadataResult = poolService.getPoolMetadata(List.of(poolListResult.getValue().get(0).getPoolIdBech32()), Options.EMPTY);
Assertions.assertTrue(metadataResult.isSuccessful());
List<PoolMetadata> poolMetadata = metadataResult.getValue();
Assertions.assertNotNull(poolMetadata);
Assertions.assertFalse(poolMetadata.isEmpty());
log.info(poolMetadata.get(0).toString());

@lucifer911
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants