JayIsHere
JayIsHere

Reputation: 35

How to get a simplified version of a Youtube subscriber count

So I am using the smiirl counter and was hoping to not have to try and scrub data after the fact instead just use google api directly... i got as far as this example below but it looks like it wont work for me if items and statistics are included, no attributes are identified for me to use in the smiirl interface...i literally can only have 1 line with subscribercount on it...is there a direct way to dig that deep?

currently getting

{
  "items": [
    {
      "statistics": {
        "subscriberCount": "3"
      }
    }
  ]
}

what i need

{
  "subscriberCount": "3"
}

Upvotes: 1

Views: 103

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116948

You appear to be using the Channels: list method.

The response returned by this method is

{
  "kind": "youtube#channelListResponse",
  "etag": etag,
  "nextPageToken": string,
  "prevPageToken": string,
  "pageInfo": {
    "totalResults": integer,
    "resultsPerPage": integer
  },
  "items": [
    channel Resource
  ]
}

You can use the fields optional parameter to reduce the fields returned. which i suspect you are already doing something like this.

FieldMask used for response filtering. If empty, all fields should be returned unless documented otherwise.

fields = items(statistics(subscriberCount)) 

That is the best your going to be able to get. You can not change the format of a response from an api endpoint.

May i suggest creating a method on your end that when the data is returned reformat it locally

Upvotes: 1

Related Questions