Graph Service

The Graph Service manages the social graphs, including follow/unfollow actions, blocking users, and other social interactions. It allows applications to maintain and query the social connections between users on the Frequency network.

API Reference

Open Full API Reference Page

Path Table

MethodPathDescription
POST/v1/graphs/getGraphsFetch graphs for specified MSA Ids and Block Number
PUT/v1/graphsRequest an update to a given user's graph
GET/v1/webhooksGet all registered webhooks
PUT/v1/webhooksWatch graphs for specified dsnpIds and receive updates
DELETE/v1/webhooksDelete all registered webhooks
GET/v1/webhooks/users/{msaId}Get all registered webhooks for a specific MSA Id
DELETE/v1/webhooks/users/{msaId}Delete all webhooks registered for a specific MSA
GET/v1/webhooks/urlsGet all webhooks registered to the specified URL
DELETE/v1/webhooks/urlsDelete all MSA webhooks registered with the given URL
GET/healthzCheck the health status of the service
GET/livezCheck the live status of the service
GET/readyzCheck the ready status of the service

Reference Table

Path Details


[POST]/v1/graphs/getGraphs

  • Summary
    Fetch graphs for specified MSA Ids and Block Number

RequestBody

  • application/json
{
  dsnpIds?: string[]
  // Graph type to query (public or private)
  privacyType: enum[private, public]
  graphKeyPairs: {
    // Public graph encryption key as a hex string (prefixed with "0x")
    publicKey: string
    // Private graph encryption key as a hex string (prefixed with "0x")
    privateKey: string
    // Key type of graph encryption keypair (currently only X25519 supported)
    keyType: enum[X25519]
  }[]
}

Responses

  • 200 Graphs retrieved successfully

application/json

{
  // MSA Id that is the owner of the graph represented by the graph edges in this object
  dsnpId: string
  dsnpGraphEdges: {
    // MSA Id of the user represented by this graph edge
    userId: string
    // Block number when connection represented by this graph edge was created
    since: number
  }[]
}[]

[PUT]/v1/graphs

  • Summary
    Request an update to a given user's graph

RequestBody

  • application/json
{
  // MSA Id that owns the connections represented in this object
  dsnpId: string
  // Array of connections known to the Provider for ths MSA referenced in this object
  connections: #/components/schemas/ConnectionDtoWrapper
  graphKeyPairs: {
    // Public graph encryption key as a hex string (prefixed with "0x")
    publicKey: string
    // Private graph encryption key as a hex string (prefixed with "0x")
    privateKey: string
    // Key type of graph encryption keypair (currently only X25519 supported)
    keyType: enum[X25519]
  }[]
  // Optional URL of a webhook to invoke when the request is complete
  webhookUrl?: string
}

Responses

  • 201 Graph update request created successfully

application/json

{
  // Reference ID by which the results/status of a submitted GraphChangeRequest may be retrieved
  referenceId: string
}

[GET]/v1/webhooks

  • Summary
    Get all registered webhooks

Responses

  • 200 Retrieved all registered webhooks

[PUT]/v1/webhooks

  • Summary
    Watch graphs for specified dsnpIds and receive updates

RequestBody

  • application/json
{
  dsnpIds?: string[]
  // Webhook URL to call when graph changes for the referenced MSAs are detected
  webhookEndpoint: string
}

Responses

  • 200 Successfully started watching graphs

[DELETE]/v1/webhooks

  • Summary
    Delete all registered webhooks

Responses

  • 200 Removed all registered webhooks

[GET]/v1/webhooks/users/{msaId}

  • Summary
    Get all registered webhooks for a specific MSA Id

Parameters(Query)

includeAll?: boolean

Responses

  • 200 Retrieved all registered webhooks for the given MSA Id

[DELETE]/v1/webhooks/users/{msaId}

  • Summary
    Delete all webhooks registered for a specific MSA

Responses

  • 200 Removed all registered webhooks for the specified MSA

[GET]/v1/webhooks/urls

  • Summary
    Get all webhooks registered to the specified URL

Parameters(Query)

url: string

Responses

  • 200 Retrieved all webhooks registered to the specified URL

[DELETE]/v1/webhooks/urls

  • Summary
    Delete all MSA webhooks registered with the given URL

Parameters(Query)

url: string

Responses

  • 200 Removed all webhooks registered to the specified URL

[GET]/healthz

  • Summary
    Check the health status of the service

Responses

  • 200 Service is healthy

[GET]/livez

  • Summary
    Check the live status of the service

Responses

  • 200 Service is live

[GET]/readyz

  • Summary
    Check the ready status of the service

Responses

  • 200 Service is ready

References

#/components/schemas/GraphKeyPairDto

{
  // Public graph encryption key as a hex string (prefixed with "0x")
  publicKey: string
  // Private graph encryption key as a hex string (prefixed with "0x")
  privateKey: string
  // Key type of graph encryption keypair (currently only X25519 supported)
  keyType: enum[X25519]
}

#/components/schemas/GraphsQueryParamsDto

{
  dsnpIds?: string[]
  // Graph type to query (public or private)
  privacyType: enum[private, public]
  graphKeyPairs: {
    // Public graph encryption key as a hex string (prefixed with "0x")
    publicKey: string
    // Private graph encryption key as a hex string (prefixed with "0x")
    privateKey: string
    // Key type of graph encryption keypair (currently only X25519 supported)
    keyType: enum[X25519]
  }[]
}

#/components/schemas/DsnpGraphEdgeDto

{
  // MSA Id of the user represented by this graph edge
  userId: string
  // Block number when connection represented by this graph edge was created
  since: number
}

#/components/schemas/UserGraphDto

{
  // MSA Id that is the owner of the graph represented by the graph edges in this object
  dsnpId: string
  dsnpGraphEdges: {
    // MSA Id of the user represented by this graph edge
    userId: string
    // Block number when connection represented by this graph edge was created
    since: number
  }[]
}

#/components/schemas/ConnectionDto

{
  // MSA Id representing the target of this connection
  dsnpId: string
  // Indicator connection type (public or private)
  privacyType: enum[private, public]
  // Indicator of the direction of this connection
  direction: enum[connectionTo, connectionFrom, bidirectional, disconnect]
  // Indicator of the type of connection (follow or friendship)
  connectionType: enum[follow, friendship]
}

#/components/schemas/ConnectionDtoWrapper

{
  data: {
    // MSA Id representing the target of this connection
    dsnpId: string
    // Indicator connection type (public or private)
    privacyType: enum[private, public]
    // Indicator of the direction of this connection
    direction: enum[connectionTo, connectionFrom, bidirectional, disconnect]
    // Indicator of the type of connection (follow or friendship)
    connectionType: enum[follow, friendship]
  }[]
}

#/components/schemas/ProviderGraphDto

{
  // MSA Id that owns the connections represented in this object
  dsnpId: string
  // Array of connections known to the Provider for ths MSA referenced in this object
  connections: #/components/schemas/ConnectionDtoWrapper
  graphKeyPairs: {
    // Public graph encryption key as a hex string (prefixed with "0x")
    publicKey: string
    // Private graph encryption key as a hex string (prefixed with "0x")
    privateKey: string
    // Key type of graph encryption keypair (currently only X25519 supported)
    keyType: enum[X25519]
  }[]
  // Optional URL of a webhook to invoke when the request is complete
  webhookUrl?: string
}

#/components/schemas/GraphChangeRepsonseDto

{
  // Reference ID by which the results/status of a submitted GraphChangeRequest may be retrieved
  referenceId: string
}

#/components/schemas/WatchGraphsDto

{
  dsnpIds?: string[]
  // Webhook URL to call when graph changes for the referenced MSAs are detected
  webhookEndpoint: string
}

Configuration

ℹ️ Feel free to adjust your environment variables to taste. This application recognizes the following environment variables:

NameDescriptionRange/TypeRequired?Default
API_PORTHTTP port that the application listens on1025 - 655353000
BLOCKCHAIN_SCAN_INTERVAL_SECONDSHow many seconds to delay between successive scans of the chain (after end of chain is reached)> 0180
CACHE_KEY_PREFIXPrefix to use for Redis cache keysstringcontent-watcher:
CAPACITY_LIMITMaximum amount of provider capacity this app is allowed to use (per epoch) type: 'percentage' 'amount' value: number (may be percentage, ie '80', or absolute amount of capacity)JSON (example)Y
DEBOUNCE_SECONDSNumber of seconds to retain pending graph updates in the Redis cache to avoid redundant fetches from the chain>= 0
FREQUENCY_URLBlockchain node addresshttp(s): or ws(s): URLY
GRAPH_ENVIRONMENT_TYPEGraph environment type.Mainnet|TestnetPaseoY
HEALTH_CHECK_MAX_RETRIESNumber of /health endpoint failures allowed before marking the provider webhook service down>= 020
HEALTH_CHECK_MAX_RETRY_INTERVAL_SECONDSNumber of seconds to retry provider webhook /health endpoint when failing> 064
HEALTH_CHECK_SUCCESS_THRESHOLDMinimum number of consecutive successful calls to the provider webhook /health endpoint before it is marked up again> 010
PROVIDER_ACCOUNT_SEED_PHRASESeed phrase for provider MSA control keystringY
PROVIDER_IDProvider MSA IdintegerY
QUEUE_HIGH_WATERMax number of jobs allowed on the 'graphUpdateQueue' before blockchain scan will be paused to allow queue to drain>= 1001000
RECONNECTION_SERVICE_REQUIREDWhether to instantiate/activate reconnection-service featurestrue/false
REDIS_URLConnection URL for RedisURLY

The following environment variables are only relevant if RECONNECTION_SERVICE_REQUESTED is 'true':

NameDescriptionRange/TypeRequired?Default
CONNECTIONS_PER_PROVIDER_RESPONSE_PAGENumber of connection/page to request when requesting provider connections from webhook> 0100
PROVIDER_ACCESS_TOKENAn optional bearer token authentication to the provider webhookstring
PROVIDER_BASE_URLBase URL for provider webhook endpointsURLY
WEBHOOK_FAILURE_THRESHOLDNumber of failures allowed in the provider webhook before the service is marked down> 03
WEBHOOK_RETRY_INTERVAL_SECONDSNumber of seconds between provider webhook retry attempts when failing> 010

Best Practices

  • Data Integrity: Ensure the integrity of social graph data by implementing robust validation checks.
  • Efficient Queries: Optimize queries to handle large social graphs efficiently.
  • User Privacy: Protect user privacy by ensuring that graph data is only accessible to authorized entities.