Skip to main content

Metadata API for schema and mutating tables


Show first post

40 replies

Chester_McLaugh wrote:

I found a half-way solution that will help in some use-cases while waiting for the metadata API.

Visit https://airtable.com/api and select a base. Then open your browsers console (Developer Tools) and run the following (I tried simply running JSON.stringify(window.application), however there are circular references so I had to manually reconstruct the properties I wanted).

var myapp = {
	id:window.application.id,
	name:window.application.name,
	tables:[]
};

for (let table of window.application.tables){

	var mytable = {
			id:table.id,
			isEmpty:table.isEmpty,
			name:table.name,
			nameForUrl:table.nameForUrl,
			primaryColumnName:table.primaryColumnName,
			columns:[]
	};

	for (let column of table.columns){
		var mycolumn = {
			id:column.id,
			name:column.name,
			type:column.type,
			typeOptions:column.typeOptions
		};

		mytable.columns.push(mycolumn);

	}

	myapp.tables.push(mytable);

}

jQuery('link[rel=stylesheet]').remove();
jQuery("body").html(JSON.stringify(myapp));
console.log(myapp);

is possible implement this code in a function with the link to url?


+1 for this feature request. It would be hugely beneficial and the community has been asking for it for years.


  • Participating Frequently
  • 7 replies
  • May 27, 2020

I agree this functionality would be very useful.


Forum|alt.badge.img+12

+1 Geeeeeeeese. Come on AT.


Sometimes it’s hard to understand whether Airtable really is trying to be a professional solution or not.


Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • July 10, 2020
aaron_altamura wrote:

+1 Geeeeeeeese. Come on AT.


Are you guys aware of the many ways that have emerged to get at the schema? Here’s one. There are others like this one, and this one.


Forum|alt.badge.img+1
  • Participating Frequently
  • 10 replies
  • August 25, 2020
Bill_French wrote:

Are you guys aware of the many ways that have emerged to get at the schema? Here’s one. There are others like this one, and this one.


Yes, because clearly a hack is much better than a proper metadata API.


Forum|alt.badge.img+4

Is the way to do this now to create a custom block? Looks like its possible through that - Airtable Blocks SDK


Forum|alt.badge.img+10
  • Known Participant
  • 14 replies
  • September 19, 2020

I know this is a bit of middle ages as you have to press the button RUN everytime you need to modify your tables…
But i got this as a compromise.

Create a new table where you will store your Schema.
I called it ‘Ledger’ just for clarity.

create a block and use this code, it will populate it with the names of your tables, and then you can use it to make api calls.

let ledger = base.getTable('Ledger');
let tableList = []

for (table of base.tables) {tableList.push({fields: {'Name' : table.name}})}

await ledger.createRecordsAsync(tableList)

if you want to avoid async random return order of your records you can store it in a string and then parse it as an array in your app.

let ledger = base.getTable('Ledger');
let tableList = ""

for (table of base.tables) {
    if (base.tables.indexOf(table) == base.tables.length - 1) {
         tableList += table.name
    }
    else {
    tableList += table.name + ", "
    }
}

await ledger.createRecordsAsync([{
            fields: {'Name' : tableList }
}])

Forum|alt.badge.img+12
Bill_French wrote:

Are you guys aware of the many ways that have emerged to get at the schema? Here’s one. There are others like this one, and this one.


Should be native, no? :frowning:


Forum|alt.badge.img+19
  • Inspiring
  • 3264 replies
  • September 21, 2020
aaron_altamura wrote:

Should be native, no? :frowning:


I don’t understand your comment. I’m very old; give me more context.


Forum|alt.badge.img+2

I would love to be able to create an object-oriented Python API for my Airtable base. The current inability to query the schema definition via the API is a problem.


Forum|alt.badge.img+12
Bill_French wrote:

I don’t understand your comment. I’m very old; give me more context.


And I’m feeling old. Perhaps best to move along :grinning_face_with_big_eyes:


Forum|alt.badge.img+11
  • Known Participant
  • 26 replies
  • October 24, 2020
Chester_McLaugh wrote:

I found a half-way solution that will help in some use-cases while waiting for the metadata API.

Visit https://airtable.com/api and select a base. Then open your browsers console (Developer Tools) and run the following (I tried simply running JSON.stringify(window.application), however there are circular references so I had to manually reconstruct the properties I wanted).

var myapp = {
	id:window.application.id,
	name:window.application.name,
	tables:[]
};

for (let table of window.application.tables){

	var mytable = {
			id:table.id,
			isEmpty:table.isEmpty,
			name:table.name,
			nameForUrl:table.nameForUrl,
			primaryColumnName:table.primaryColumnName,
			columns:[]
	};

	for (let column of table.columns){
		var mycolumn = {
			id:column.id,
			name:column.name,
			type:column.type,
			typeOptions:column.typeOptions
		};

		mytable.columns.push(mycolumn);

	}

	myapp.tables.push(mytable);

}

jQuery('link[rel=stylesheet]').remove();
jQuery("body").html(JSON.stringify(myapp));
console.log(myapp);

I tried this and it works great!. I save the json out to a file, then load it into python / dataframe for various uses. Thanks Chester.


Forum|alt.badge.img+3

See this info about the newly launched Metadata API: Accessing the metadata API.


Reply