0

I have a sample dataset looking like this:

"id": 1,
        "name": "meow",
        "address": "123 meowmeow St, city, state 12345",
        "users": [
            {
                "id": 1,
                "initials": "L.L",
                "checkIn": []
             }]
              

with this code

url_API = "https://blah.com/organizations/api-key/organizations?apiKey=blahblah"

response_API = requests.get(url_API)

data = response_API.text
parse_json = json.loads(data)

yFile = json.dumps(parse_json, indent=4)
print(yFile)

Is there a way to download just certain field from the url? I understand I can manipulate the dataset "after" I download it all. But for a purpose, I don't want this field to be visible at all from the downloaded data response. For example: I don't want to download the field "initial" and "address", just the remaining below.

"id": 1,
        "name": "meow",
        "users": [
            {
                "id": 1,
                "checkIn": []
             }]

Is there a way to do it? Or I absolutely must download all data then select subset?

I tried to look up example, the only thing I found that is similar is from https://jsonapi.org/examples/, example 2 code. It does not say how I can build the url string for requests.get. Please help. Much appreciated.

1 Answers1

0

Unless the api has a fields parameter of some kind, which would allow you to return only the fields you would need, it is not possible without fetching all and manipulating the response.

rtyocum
  • 11
  • 2