Skip to content

Instantly share code, notes, and snippets.

@coletdjnz
Last active October 2, 2022 16:22
Show Gist options
  • Save coletdjnz/472856c0729958c2fb5371acd650bf4e to your computer and use it in GitHub Desktop.
Save coletdjnz/472856c0729958c2fb5371acd650bf4e to your computer and use it in GitHub Desktop.
Filtering fields from googleapi results (including Innertube)

System parameter common to all googleapis for filtering fields

query parameter header
fields X-Goog-FieldMask

FieldMask contains a list of paths

Basics

  • Specify multiple field paths by seperating with a comma
  • A field path can be indexed with a . or /
  • Sub-paths can be specified within ()
  • Can specify all fields with *

Example

  • e.g. {a:[a,b,c]}
  • to only get {a:[c]} you would use a/c or a.c or a(c)
  • To include both b and c to get {a:[b,c]} you can use a(b,c)

Example 2

  • e.g. {a:[a,b,c],d:[e,f]}
  • a(b,c),d.f will return {a:[b,c],d:[f]}
  • a(*) or a will return {a:[a,b,c]}

Remarks

  • Default is * (i.e. X-Goog-FieldMask: *) (return all). This may be configured differently across APIs.
  • Specifying a field that does not exist or no longer exists will return an error
  • I don't think there is a way to exclude a field and get all others

Further information

@coletdjnz
Copy link
Author

credit to @Prototaxis for helping consolidate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment