メインコンテンツまでスキップ

Profiles

A profile is made up of a user's biographical information — display name, avatar, banner, and bio — along with their posts. This guide covers reading any user's profile and editing your own.

Viewing a profile

備考

To learn how to fetch a user's posts, see the Viewing feeds tutorial under "Author feeds."

Fetching a user's profile info

To fetch a user's profile info, you can call the app.bsky.actor.getProfile endpoint.

app.bsky.actor.getProfile
import { app } from '@bsky/sdk/lexicons'

const { did, displayName } = await client.call(app.bsky.actor.getProfile, {
actor: 'did:plc:...',
})
ParameterTypeDescriptionRequired
actorstringThe DID (or handle) of the user whose profile you'd like to fetchYes

Fetching multiple profiles at once

Fetching multiple profiles is as easy as fetching a single profile:

app.bsky.actor.getProfiles
const { profiles } = await client.call(app.bsky.actor.getProfiles, {
actors: ['did:plc:...'],
})
ParameterTypeDescriptionRequired
actorsstring[]The DIDs (or handles) of the users whose profiles you'd like to fetchYes

Editing a profile

An authenticated user can edit their profile, including updating their display name, avatar, banner image, and bio.

Editing a profile works as an "upsert" operation. If the profile does not exist, such as immediately after account creation, the profile will be created. And if the profile already exists, you must merge in new values manually and return result to be updated.

注記

The TypeScript SDK provides a convenient upsertProfile action, shown below. Where an SDK doesn't have an equivalent, edit your profile directly: read the app.bsky.actor.profile record at rkey self, change the fields you want, and write it back with a put-record call (in Go, build an appbsky.ActorProfile and submit it with comatproto.RepoPutRecord).

upsertProfile
import { upsertProfile } from '@bsky/sdk'

await client.call(upsertProfile, existing => ({
...existing,
displayName: 'New display name who dis',
description: 'New bio who dis',
}))
ヒント

Only accounts with a valid profile are indexed for search. When creating a new account, we recommend creating a minimal profile with displayName set to the user's handle.

Updating profile avatar or banner

Images are handled as separate records by Bluesky, so adding or updating an avatar or profile banner requires an additional step of uploading the image blob to your PDS.

upsertProfile
const avatar = 'data:image/png;base64,...'

await client.call(upsertProfile, async existing => {
const { body } = await client.uploadBlob(convertDataURIToUint8Array(avatar), {
encoding: 'image/png',
})

return { ...existing, avatar: body.blob }
})

Looking for more? Browse additional tutorials and guides on atproto.com.