Let's say if you follow the first guide to set up your own Appwrite on Linode already, now you want to start using it, but there are no sample data to play around with?
Let's go through these steps today.
- Create your sample data structure in Appwrite
- Setup the API connection on Appwrite to Import
- Use Integromat to import data to Appwrite through API
I m planning to import sample data from JSONPlaceholder to my Appwrite instance to try out. First, I need to create the same data structure in my Appwrite instance.
Click on Database -> Add Collection -> Fill in the name of Collection you will create; let's call it images since I will import the images sample data.
Once the Collection has been created, click the Setting; under Rules, you can start adding each field, follow our sample data structure, and create all fields completely.
- albumId as numeric - used to group the images
- id as numeric - the unique id for the image
- title as text - image title
- URL as URL - yes Appwrite support URL field, the image URL
- thumbnailUrl as URL - this is the image thumbnail URL
When you create a field, you can see that 'Label' is the field label you will see, and Key is the actual key field for the value. For example, you can put "Thumbnail URL" as a label, and the key is thumbnailUrl.
Once the Collection is created, let's get ready for the API setup part, I would like to get all my API related info ready before I proceed to Integromat to set up the import.
I like to use PAW to test all the API endpoints on my Mac, so I usually use PAW to set up & try the API first.
- You can find the API endpoint on the App Settings page, it should be your /v1 in this format.
- Project ID, on the app setting page, you can see the Project ID as well; this will be used as part of the Header - X-Appwrite-Project
- Go to the API Key section and create your API key; remember to grant access for the document, which includes ( documents.read and documents.write ); this will give the API Key to read and write Collection. We are going to use this as part of the Header X-Appwrite-key
- Finally prepare the document endpoint. It will be in this format /POST/v1/database/collections/ , you can get the collection id on the Documents Setting page.
Once you have all the info, try to make a POST request to make sure everything works before moving over to Integromat.
We are at the last step of importing data, setup the Intergormat. There will be three parts that need to be working for this importing data.
Step 1 - Let's add an HTTP request, use the GET method to get the sample data.
Step 2 - Turn the results data into JSON format; one of the easier ways is to copy the data structure from PAW just now to map the JSON data nicely.
Step 3 - Do the HTTP POST to the Appwrite API; a nice trick you can use is to filter the id below 3; this allows us to test the integration first before mass importing all the data. You can You can adjust the number to decide how many records you want to import. The full HTTP POST will be like the image below.
You should have imported some data; you can test the rest of the API endpoints to query these data. Next post, we going to share how to display these data on Adalo