REST API Examples
Hello World: A Guide to the MemMachine RESTful API
This guide provides a quick and simple way to get started with the MemMachine RESTful API usingcurl
commands. It can also be found in our Quick Start Guide.
Prerequisites
First, make sure your FastAPI application is running. Open your terminal, navigate to the directory containing yourapp.py
file, and run the following command. The output should confirm that the server is listening for requests.
1
Get All Sessions
The simplest way to start is by checking for existing sessions. This
GET
request doesn’t require any data. You will likely see an empty list since no sessions have been created yet.2
Add a New Memory
This is where you’ll create your first memory episode. The Expected Output:You will receive an empty
POST /v1/memories
endpoint requires a JSON body that includes session details, a producer, a recipient, and the content of the memory itself.Command:200 OK
response, confirming the memory was added successfully.3
Search for the Memory
Now that a memory has been added, let’s try to find it. The Expected Output:You should see a
POST /v1/memories/search
endpoint also requires a JSON body to specify the search query and session.Command:200 OK
response containing the search results, including the memory episode you just added. The output will be formatted as a JSON object, confirming that your memory was successfully found.4
Delete the Session Data
To clean up after your test, you can use the
DELETE /v1/memories
endpoint. This also requires a JSON body to specify which session’s data should be removed.Command: