Comments (6)
@tedmoorman the "index" referred to in the API docs should probably be explained better. We're talking about the index of the distribution array. DKAN can have multiple distributions/resources associated with one dataset record, but on the Open Payments website there is only a single distribution for each dataset. So the "index" on datastore API queries will always be "0".
To paginate through the data use the "limit" and "offset" parameters in the request itself.
You can also use the "download" endpoint with "format" = "csv" to stream the full response as a CSV file. We can't currently stream data in JSON format but may add this capability in the future.
from dkan.
I added '"format": "csv"' to the JSON portion of the request. In the API tool on the page, I see a download link: blob:https://openpaymentsdata.cms.gov/4aaa8ac9-9bcb-4f98-a99d-0e2eb04f9a51 . (See screen shot below).
I don't see this URL in any of the output (in my programming interface). How do I locate that URL? Or, is there a way I need to format the JSON portion of my request to "use the 'download' endpoint"?
Not sure how to do this. Thank you for your help.
from dkan.
@tedmoorman the documentation on the specific datasets page is kind of minimal, there are additional endpoints described at https://openpaymentsdata.cms.gov/about/api
For instance for your request you could do a simple GET request to
The POST version of this would be
POST https://openpaymentsdata.cms.gov/api/1/datastore/query/0380bbeb-aea1-58b6-b708-829f92a48202/0/download
{
"format": "csv"
}
You can then add any filters or other query elements you wish. It's not really necessary to perform an API request if you just want a CSV file of the full dataset without any filters; simply download the original CSV file linked from the dataset.
And of course you can also use the distribution ID instead of the dataset ID without the "/0" on the end, but I would reccomend sticking to the [dataset ID]/[index] endpoint, as distribution IDs can change over time but dataset IDs should not. Again, we should explain this better in the dataset-specific API docs.
from dkan.
@dafeder Well, that's definitely what I was missing!
Any idea how I create an "OR" condition in the JSON part of a POST request?
For example, how might I edit this?
{
"name": "dan",
"or",
"name": "ted"
}
Thank you again!
from dkan.
See the request schema in any of the datastore POST endpoints on that API docs page. I believe for your example it would look like:
{
"conditions": [
{
"groupOperator": "or",
"conditions": [
{
"property": "name",
"value": "dan"
},
{
"property": "name",
"value": "tod"
}
]
}
]
}
for AND the condition group isn't necessary, you can just do:
{
"conditions": [
{
"property": "name",
"value": "dan"
},
{
"property": "name",
"value": "tod"
}
]
}
from dkan.
@dafeder thank you so much, Dan!
The example you gave is exactly what I was looking for. Works like a charm!
from dkan.
Related Issues (20)
- /health or /status API Endpoint HOT 2
- Don't require file_public_base_url to be set manually HOT 3
- [BUG] Warning: Undefined array key "value_referencer" in Drupal\Core\Logger\LoggerChannel->log() HOT 3
- [Feature] New permission for administering metastore settings
- Small inconsistency naming DKAN dataset/content overview (admin/dkan/datasets) HOT 2
- Visualizations HOT 1
- [BUG] Dereferencer fails logging a property node that was deleted while still being referenced HOT 1
- Search indexing only supports two levels of JSON nesting
- Broken diagram image on DKAN metastore document page HOT 1
- UX Review Guidance for FE
- Determine font and content style guide for DKAN
- Put DKAN on D.O. HOT 4
- Datastore MySQL Import handles empty file incorrect
- Extending QueryDownloadController leads to fatal error from private constant
- mb_strlen() error when saving an upload_or_link url
- Create a Code of Conduct HOT 2
- Remove defensive pre-fixing of column headers with MySQL reserved words
- harvest_update_8007 did not execute harvestRunsUpdate
- Converting runs from old harvest_ID_runs to harvest_runs fails if duplicate time stamps HOT 2
- Add option for Mysql Import to support removing empty rows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkan.