Package: community-tulip-api
community-tulip-apiThis package wraps the Tulip API. This is not an official Tulip package.If you are just getting started with the Tulip API I recommend readingthis support article.AuthenticatingThis package provides 3 methods of authenticating with Tulip.Environment VariableAPI Key & Secretbase64 encoded auth stringEnvironment VariableSet an environment variableTULIP_AUTHwith base64 encoded{username}.{password}value of your bot user. After creating a bot this value can be found underAuth Headerand will look likeBasic {credential}.export TULIP_AUTH=YXBpa2V5LjJfQzU5a0w4YWdMNndBSDZOM3Y6UmlsS1V3a3pIZ0ZPc19MUkczWFQ3djdaN0tZVEZpZVVscG1WTmR5QllLaQ==fromtulip_apiimportTulipAPIapi=TulipAPI("abc.tulip.co")API Key & SecretPass in the API Key name and Secret to theTulipAPIclass.Example:fromtulip_apiimportTulipAPIapi=TulipAPI("abc.tulip.co",api_key="apikey.2_C59kL8agL6wAH6N3v",api_key_secret="RilKUwkzHgFOs_LRG3XT7v7Z7KYTFieUlpmVNdyBYKi",)Base64 encoded auth stringPass in the base64 encoded auth string. This would be the same value that the environment variables expects.Example:fromtulip_apiimportTulipAPIapi=TulipAPI("abc.tulip.co",auth="YXBpa2V5LjJfQzU5a0w4YWdMNndBSDZOM3Y6UmlsS1V3a3pIZ0ZPc19MUkczWFQ3djdaN0tZVEZpZVVscG1WTmR5QllLaQ==")TulipTable ClassTable objects reflect the current state of a table.Create Table ObjectPass the Table ID (from the table UI) and the TulipAPI object to create a TulipTable object.Example:fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBTulipTable.create_record(data)Create a record in a Tulip Table Object. The record data must be a json encoded dict with each key matching the unique field Ids in the TableUI. Not all fields in the table must be populated.Thecreate_random_idparameter is an optional attribute that will automatically set a record id if one hasn’t been givenExample:fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBrecord_data={'id':'123456','asfkha_field1':12,'fhasif_field2':True}table.create_record(record_data)TulipTable.update_record(record_id, data)Update the record in a given table with a specific id. The record data must be a json encoded dict with each key matching the unique field Ids in the TableUI. Not all fields in the table must be populated.Example:fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBrecord_data={'asfkha_field1':12,'fhasif_field2':True}table.update_record('123',record_data)TulipTable.delete_record(record_id)Update the record with the given record id.Example:fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBtable.delete_record('1234')TulipTable.get_record(record_id)Returns the json encoded data from a single record with the given record id.fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBrec_data=table.get_record("1234")TulipTable.get_records()Returns a list of records. This is limited to 100 records, but theoffsetparameter can be leveraged to loop through all of the records in a table.fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBrecs_data=table.get_records()TulipTable.stream_records()Stream table records from a Tulip Table. This will progressively return records in a table. All Table records will be returned as they are available. This is the most performative way to do anything with all of the records in a table.fromtulip_apiimportTulipAPI,TulipTableapi=TulipAPI("abc.tulip.co")table=TulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBforrecordintable.stream_records():print(record)#DO SOMETHINGCachedTulipTable ClassReflects a cached representation of a Tulip Table for more performative bulk data operations. The table is stored to memory.Create Cached Tulip Table Objectfromtulip_apiimportTulipAPI,CachedTulipTableapi=TulipAPI("abc.tulip.co")table=CachedTulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBCachedTulipTable.update_data()Forces the update of a cached Tulip Tablefromtulip_apiimportTulipAPI,CachedTulipTableapi=TulipAPI("abc.tulip.co")table=CachedTulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBtable.update_data()CachedTulipTable.get_record(record_id)Returns the cached data from a Tulip Table with the associatedrecord_id.fromtulip_apiimportTulipAPI,CachedTulipTableapi=TulipAPI("abc.tulip.co")table=CachedTulipTable(api,'bQLv6iMsau4ipqRiB')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBtable.get_record("1234")TulipTableLink ClassRepresents the linked records between two Tulip Tables with theLinked Recordtype Table field.The link id is the prefix for the field id in the table.For example, Table fieldcrN9z6v6qXidrj8TX_link_right_columnhas the link idcrN9z6v6qXidrj8TXCreate Tulip Table Link Objectfromtulip_apiimportTulipAPI,TulipTableLinkapi=TulipAPI("abc.tulip.co")link=TulipTableLink(api,'crN9z6v6qXidrj8TX')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBTulipTableLink.link_records(left_record_id,right_record_id)Links the records in 2 tables based on the record IDs in each table. Theleftandrightrecord definition is included in the table record field id’s (ex:crN9z6v6qXidrj8TX_link_right_column)fromtulip_apiimportTulipAPI,TulipTableLinkapi=TulipAPI("abc.tulip.co")link=TulipTableLink(api,'crN9z6v6qXidrj8TX')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBlink.link_records('1234','5678')TulipTableLink.unlink_records(left_record_id,right_record_id)Unlinks the records in 2 tables based on the record IDs in each table. Theleftandrightrecord definition is included in the table record field id’s (**ex:crN9z6v6qXidrj8TX_link_right_column)fromtulip_apiimportTulipAPI,TulipTableLinkapi=TulipAPI("abc.tulip.co")link=TulipTableLink(api,'crN9z6v6qXidrj8TX')# table url: https://abc.tulip.co/table/bQLv6iMsau4ipqRiBlink.unlink_records('1234','5678')