List Projects
curl --request GET \
--url http://localhost:8001/api/v2/projects/list \
--header 'x-api-key: <api-key>'import requests
url = "http://localhost:8001/api/v2/projects/list"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('http://localhost:8001/api/v2/projects/list', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8001",
CURLOPT_URL => "http://localhost:8001/api/v2/projects/list",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:8001/api/v2/projects/list"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:8001/api/v2/projects/list")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8001/api/v2/projects/list")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"repo_name": "my-awesome-app",
"status": "ready"
},
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"repo_name": "backend-api",
"status": "processing"
}
]{
"detail": "Invalid API key"
}Potpie API
List Projects
Get a list of all projects using API key authentication
GET
/
api
/
v2
/
projects
/
list
List Projects
curl --request GET \
--url http://localhost:8001/api/v2/projects/list \
--header 'x-api-key: <api-key>'import requests
url = "http://localhost:8001/api/v2/projects/list"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('http://localhost:8001/api/v2/projects/list', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8001",
CURLOPT_URL => "http://localhost:8001/api/v2/projects/list",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:8001/api/v2/projects/list"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:8001/api/v2/projects/list")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8001/api/v2/projects/list")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"repo_name": "my-awesome-app",
"status": "ready"
},
{
"id": "123e4567-e89b-12d3-a456-426614174001",
"repo_name": "backend-api",
"status": "processing"
}
]{
"detail": "Invalid API key"
}Use Cases
- Display available projects in your application
- Verify a project exists before creating conversations
- Check project parsing status and metadata
- Build project selection interfaces
- Monitor project creation and management
Authentication
This endpoint requires API key authentication via thex-api-key header.
x-api-key: YOUR_API_KEY
Request & Response
Request & Response
| Location | Field | Type | Required | Description |
|---|---|---|---|---|
| Response | id | string | - | Unique project identifier (UUID) - use this for conversations and searches |
| Response | repo_name | string | - | Repository name (e.g., “facebook/react”) |
| Response | status | string | - | Current project status (see Project Status table below) |
Project Status
Projects can have different statuses:| Status | Description | Actions Available |
|---|---|---|
submitted | Parsing queued but not started | Wait for processing |
cloned | Repository cloned successfully | Wait for processing |
parsed | Code structure analyzed | Wait for processing |
processing | Building knowledge graph | Wait for completion |
inferring | Generating knowledge graph inferences | Wait for completion |
ready | Ready for use | All operations available |
error | Parsing failed | Review errors, retry parsing |
Error Responses
401 Unauthorized
401 Unauthorized
The endpoint requires a valid API key for authentication.Causes:
{
"detail": "API key is required"
}
- Missing
x-api-keyheader - Invalid or expired API key
- API key doesn’t match any user account
x-api-key: YOUR_API_KEY
500 Internal Server Error
500 Internal Server Error
The endpoint returns this error when unexpected exceptions occur.Causes:
{
"detail": "<exception message>"
}
- Database connection failures
- Service unavailability
Complete Workflow
const response = await fetch(
'http://localhost:8001/api/v2/projects/list',
{
headers: {
'x-api-key': 'YOUR_API_KEY'
}
}
);
const projects = await response.json();
console.log(`Total projects: ${projects.length}`);
projects.forEach(project => {
console.log(`- ${project.repo_name} - ${project.status}`);
});
import requests
response = requests.get(
'http://localhost:8001/api/v2/projects/list',
headers={'x-api-key': 'YOUR_API_KEY'}
)
projects = response.json()
print(f"Total projects: {len(projects)}")
for project in projects:
print(f"- {project['repo_name']} - {project['status']}")
# List all projects
curl -X GET \
'http://localhost:8001/api/v2/projects/list' \
-H 'x-api-key: YOUR_API_KEY'
# Pretty print with jq
curl -X GET \
'http://localhost:8001/api/v2/projects/list' \
-H 'x-api-key: YOUR_API_KEY' | jq '.'
Building a Project Dashboard
// React component example
import { useEffect, useState } from 'react';
interface Project {
id: string;
repo_name: string;
status: string;
}
function ProjectDashboard() {
const [projects, setProjects] = useState<Project[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function loadProjects() {
try {
const response = await fetch(
'http://localhost:8001/api/v2/projects/list',
{
headers: {
'x-api-key': process.env.POTPIE_API_KEY
}
}
);
const data = await response.json();
setProjects(data);
} catch (error) {
console.error('Failed to load projects:', error);
} finally {
setLoading(false);
}
}
loadProjects();
}, []);
if (loading) return <div>Loading projects...</div>;
return (
<div>
<h2>Your Projects ({projects.length})</h2>
<ul>
{projects.map(project => (
<li key={project.id}>
<strong>{project.repo_name}</strong>
<span className={`status ${project.status}`}>
{project.status}
</span>
</li>
))}
</ul>
</div>
);
}
Filtering and Sorting
// Filter projects by status
const readyProjects = projects.filter(p => p.status === 'ready');
const processingProjects = projects.filter(p => p.status === 'processing');
// Sort by name alphabetically
const alphabeticalProjects = [...projects].sort((a, b) =>
a.repo_name.localeCompare(b.repo_name)
);
// Group by status
const projectsByStatus = projects.reduce((acc, project) => {
if (!acc[project.status]) {
acc[project.status] = [];
}
acc[project.status].push(project);
return acc;
}, {});
Common Patterns
Project Selector Component
function ProjectSelector({ onSelect }: { onSelect: (projectId: string) => void }) {
const [projects, setProjects] = useState<Project[]>([]);
useEffect(() => {
fetchProjects().then(setProjects);
}, []);
const readyProjects = projects.filter(p => p.status === 'ready');
return (
<select onChange={(e) => onSelect(e.target.value)}>
<option value="">Select a project...</option>
{readyProjects.map(project => (
<option key={project.id} value={project.id}>
{project.repo_name}
</option>
))}
</select>
);
}
Project Validation
async function validateProject(projectId: string): Promise<boolean> {
const projects = await getProjects();
const project = projects.find(p => p.id === projectId);
if (!project) {
console.error(`Project ${projectId} not found`);
return false;
}
if (project.status !== 'ready') {
console.error(`Project ${projectId} is not ready (status: ${project.status})`);
return false;
}
return true;
}
Troubleshooting
Empty project list
Empty project list
Problem: API returns an empty array
[].Solution:- This is normal if you haven’t created any projects yet
- Use the Parse Directory endpoint to create your first project
- Verify you’re using the correct API key for your account
- Check that projects weren’t accidentally deleted
Projects missing from list
Projects missing from list
Problem: Some projects don’t appear in the response.Solution:
- Projects are user-specific - ensure you’re using the correct API key
- Check if projects were deleted or archived
- Verify the projects completed parsing successfully
- Contact support if projects are definitely missing
Status shows 'error'
Status shows 'error'
Problem: Project status indicates parsing failure.Solution:
- Use the Get Parsing Status endpoint to get detailed error information
- Check if the repository is accessible
- Verify the branch exists
- Try re-parsing the repository with the Parse Directory endpoint
Authorizations
API key authentication. Get your key from potpie settings page
Was this page helpful?

