GithubHelp home page GithubHelp logo

Comments (6)

dafeder avatar dafeder commented on September 22, 2024

@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.

tedmoorman avatar tedmoorman commented on September 22, 2024

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).
image
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.

dafeder avatar dafeder commented on September 22, 2024

@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

https://openpaymentsdata.cms.gov/api/1/datastore/query/0380bbeb-aea1-58b6-b708-829f92a48202/0/download?format=csv

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.

tedmoorman avatar tedmoorman commented on September 22, 2024

@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.

dafeder avatar dafeder commented on September 22, 2024

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.

tedmoorman avatar tedmoorman commented on September 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.