Skip to main content

Writing Follows to Your Graph

Follows represent a follow relationship between two users. Creating follows is easy. Simply pass in the id or the username of the user creating the follow (i.e. the follower) into the startId field, and id or the username of the follow recipient (i.e. the followee) into the endId field. Use the same id you used when creating the profile.

Here’s an example command that makes user marcus follow user nehemiah .

await fetch('https://api.usetapestry.dev/v1/followers/add?apiKey=YOUR_API_KEY', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
startId: 'marcus',
endId: 'nehemiah',
}),
})

To check if the follow succeeded, you can GET the followers count of the user who received the follow. In this example, we'll ask for nehemiah's followers count:

await fetch(
'https://api.usetapestry.dev/v1/profiles/followers/__STARTID__?apiKey=YOUR_API_KEY',
)

and you can also check the following count of the user who performed the follow. In this example, we'll ask for marcus's following count:

await fetch(
'https://api.usetapestry.dev/v1/profiles/following/__STARTID__?apiKey=YOUR_API_KEY',
)