{"_path":"/api/kv","_draft":false,"_partial":false,"_empty":false,"title":"Key-Value Store","description":"Lanyard KV is a a dynamic, real-time key->value store which is added to the Lanyard user API response. When a KV pair is updated, a PRESENCE_UPDATE for the user will also be emitted through the Lanyard socket.","excerpt":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"key-value-store"},"children":[{"type":"text","value":"Key-Value Store"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Lanyard KV is a a dynamic, "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"real-time"}]},{"type":"text","value":" key->value store which is added to the Lanyard user API response. When a KV pair is updated, a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PRESENCE_UPDATE"}]},{"type":"text","value":" for the user will also be emitted through the Lanyard socket."}]},{"type":"element","tag":"h3","props":{"id":"use-cases"},"children":[{"type":"text","value":"Use Cases"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Configuration values for your website"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Configuration values for Lanyard 3rd party projects"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Dynamic data for your website/profile (e.g. current location)"}]}]},{"type":"element","tag":"h3","props":{"id":"limits"},"children":[{"type":"text","value":"Limits"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Keys and values can only be strings"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Values can be 30,000 characters maximum"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Keys must be alphanumeric (a-zA-Z0-9) and 255 characters max length"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Your user can have a maximum of 512 key->value pairs linked"}]}]},{"type":"element","tag":"h3","props":{"id":"getting-an-api-key"},"children":[{"type":"text","value":"Getting an API Key"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"DM the Lanyard bot ("},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Lanyard#5766"}]},{"type":"text","value":") with "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".apikey"}]},{"type":"text","value":" to get your API key."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When making Lanyard KV API requests, set an "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Authorization"}]},{"type":"text","value":" header with the API key you received from the Lanyard bot as the value."}]},{"type":"element","tag":"h3","props":{"id":"setting-a-key-value-pair"},"children":[{"type":"text","value":"Setting a key->value pair"}]},{"type":"element","tag":"h4","props":{"id":"discord"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{"lang":"ts"},"children":[{"type":"text","value":".set "}]}]},{"type":"element","tag":"h4","props":{"id":"http"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PUT https://api.lanyard.rest/v1/users/:user_id/kv/:key"}]},{"type":"text","value":"\nThe value will be set to the body of the request. The body can be any type of data, but it will be string-encoded when set in Lanyard KV."}]},{"type":"element","tag":"h3","props":{"id":"setting-multiple-key-value-pairs"},"children":[{"type":"text","value":"Setting multiple key->value pairs"}]},{"type":"element","tag":"h4","props":{"id":"discord-1"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Not yet implemented"}]},{"type":"element","tag":"h4","props":{"id":"http-1"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PATCH https://api.lanyard.rest/v1/users/:user_id/kv"}]},{"type":"text","value":"\nThe user's KV store will be merged with the body of the request. Conflicting keys will be overwritten. The body must be keyvalue pair object with a maximum depth of 1."}]},{"type":"element","tag":"h3","props":{"id":"deleting-a-key"},"children":[{"type":"text","value":"Deleting a key"}]},{"type":"element","tag":"h4","props":{"id":"discord-2"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{"lang":"ts"},"children":[{"type":"text","value":".del "}]}]},{"type":"element","tag":"h4","props":{"id":"http-2"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"DELETE https://api.lanyard.rest/v1/users/:user_id/kv/:key"}]}]}]},"head":{"meta":[{"name":"og:title","property":"og:title","content":"Key-Value Store"},{"name":"twitter:title","property":"twitter:title","content":"Key-Value Store"},{"name":"description","property":"description","content":"Use Lanyard KV to display dynamic and real-time updated data through Lanyard API."},{"name":"og:description","property":"og:description","content":"Use Lanyard KV to display dynamic and real-time updated data through Lanyard API."},{"name":"twitter:description","property":"twitter:description","content":"Use Lanyard KV to display dynamic and real-time updated data through Lanyard API."}]},"body":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"key-value-store"},"children":[{"type":"text","value":"Key-Value Store"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Lanyard KV is a a dynamic, "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"real-time"}]},{"type":"text","value":" key->value store which is added to the Lanyard user API response. When a KV pair is updated, a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PRESENCE_UPDATE"}]},{"type":"text","value":" for the user will also be emitted through the Lanyard socket."}]},{"type":"element","tag":"h3","props":{"id":"use-cases"},"children":[{"type":"text","value":"Use Cases"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Configuration values for your website"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Configuration values for Lanyard 3rd party projects"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Dynamic data for your website/profile (e.g. current location)"}]}]},{"type":"element","tag":"h3","props":{"id":"limits"},"children":[{"type":"text","value":"Limits"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Keys and values can only be strings"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Values can be 30,000 characters maximum"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Keys must be alphanumeric (a-zA-Z0-9) and 255 characters max length"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Your user can have a maximum of 512 key->value pairs linked"}]}]},{"type":"element","tag":"h3","props":{"id":"getting-an-api-key"},"children":[{"type":"text","value":"Getting an API Key"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"DM the Lanyard bot ("},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Lanyard#5766"}]},{"type":"text","value":") with "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".apikey"}]},{"type":"text","value":" to get your API key."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When making Lanyard KV API requests, set an "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Authorization"}]},{"type":"text","value":" header with the API key you received from the Lanyard bot as the value."}]},{"type":"element","tag":"h3","props":{"id":"setting-a-key-value-pair"},"children":[{"type":"text","value":"Setting a key->value pair"}]},{"type":"element","tag":"h4","props":{"id":"discord"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{"lang":"ts","class":"colored"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#E06C75"}},"children":[{"type":"text","value":"set"}]},{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#56B6C2"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#E06C75"}},"children":[{"type":"text","value":"key"}]},{"type":"element","tag":"span","props":{"style":{"color":"#56B6C2"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":" <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#E5C07B"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":">"}]}]}]},{"type":"element","tag":"h4","props":{"id":"http"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PUT https://api.lanyard.rest/v1/users/:user_id/kv/:key"}]},{"type":"text","value":"\nThe value will be set to the body of the request. The body can be any type of data, but it will be string-encoded when set in Lanyard KV."}]},{"type":"element","tag":"h3","props":{"id":"setting-multiple-key-value-pairs"},"children":[{"type":"text","value":"Setting multiple key->value pairs"}]},{"type":"element","tag":"h4","props":{"id":"discord-1"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Not yet implemented"}]},{"type":"element","tag":"h4","props":{"id":"http-1"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"PATCH https://api.lanyard.rest/v1/users/:user_id/kv"}]},{"type":"text","value":"\nThe user's KV store will be merged with the body of the request. Conflicting keys will be overwritten. The body must be keyvalue pair object with a maximum depth of 1."}]},{"type":"element","tag":"h3","props":{"id":"deleting-a-key"},"children":[{"type":"text","value":"Deleting a key"}]},{"type":"element","tag":"h4","props":{"id":"discord-2"},"children":[{"type":"text","value":"Discord"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{"lang":"ts","class":"colored"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#E06C75"}},"children":[{"type":"text","value":"del"}]},{"type":"element","tag":"span","props":{"style":{"color":"#ABB2BF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#56B6C2"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#E06C75"}},"children":[{"type":"text","value":"key"}]},{"type":"element","tag":"span","props":{"style":{"color":"#56B6C2"}},"children":[{"type":"text","value":">"}]}]}]},{"type":"element","tag":"h4","props":{"id":"http-2"},"children":[{"type":"text","value":"HTTP"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"DELETE https://api.lanyard.rest/v1/users/:user_id/kv/:key"}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"use-cases","depth":3,"text":"Use Cases"},{"id":"limits","depth":3,"text":"Limits"},{"id":"getting-an-api-key","depth":3,"text":"Getting an API Key"},{"id":"setting-a-key-value-pair","depth":3,"text":"Setting a key->value pair"},{"id":"setting-multiple-key-value-pairs","depth":3,"text":"Setting multiple key->value pairs"},{"id":"deleting-a-key","depth":3,"text":"Deleting a key"}]}},"_type":"markdown","_id":"content:api:kv.md","_source":"content","_file":"api/kv.md","_extension":"md"}