Access Knack object properties via API

Hi all,

I'm wondering if anyone knows how to get a list of all the properties for a specific object using Knack's API? For example, if I have an object called `Reports`, and it has a M/C field called `MyOptions` with `Option 1`, `Option 2`, and `Option 3` as the possible values, is there an API request that would return information about this object like so:

{
"object": "Reports",
"fields": [
0: {
"id": "field_23",
"name": "MyOptions",
"type": "M/C",
"values": [
"Option 1",
"Option 2",
"Option 3"
]
},
1: {
...
},
...
]
}

I can't find anything in the developer docs that suggests that this is possible, but it seems like a pretty important feature to omit. Any suggestions would be much appreciated.

Yep, that's the one. Thanks Conan!

Using the API Key in a server request, you can get the entire application object which has what you want. So like in express using axios, here's what I would do:

const applicationId = `xxxxxxx`
const resourceUrl = `https://api.knack.com/v1/applications/${applicationId}`

// ~server/api/application.js
// your-router-function-here ...

axios.get(resourceUrl)
  .then(( {data} ) => {

    const objectsArray = data.application.objects
    const reportsObject = objectsArray.find(o => o.name === 'Reports')
    if (reportsObject) {
       const myOptionsFieldObject = reportsObject.fields.find(f => f.name === 'MyOptions')
       const optionsArray = myOptionsFieldObject.format.options
       res.json(optionsArray)
    }

Obviously you will want error checking and closure in that snippet, but the take away should be that you want to get the application object from the url:

https://api.knack.com/v1/applications/my-application-id-here

then use this super crude object path:

application.objects.fields.format.options