Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor API endpoints to use pluralized paths for consistency

Bill Yang6e34ed095247
diff --git a/client/src/api/analytics/funnels/useDeleteFunnel.ts b/client/src/api/analytics/funnels/useDeleteFunnel.ts
index b1fa34f97..8d968f93b 100644
--- a/client/src/api/analytics/funnels/useDeleteFunnel.ts
+++ b/client/src/api/analytics/funnels/useDeleteFunnel.ts
@@ -1,4 +1,5 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { useStore } from "../../../lib/store";
import { authedFetch } from "../../utils";
/**
@@ -6,11 +7,12 @@ import { authedFetch } from "../../utils";
*/
export function useDeleteFunnel() {
const queryClient = useQueryClient();
+ const { site } = useStore();
return useMutation<{ success: boolean }, Error, number>({
mutationFn: async reportId => {
try {
- return await authedFetch<{ success: boolean }>(`/funnel/${reportId}`, undefined, {
+ return await authedFetch<{ success: boolean }>(`/funnels/${reportId}/${site}`, undefined, {
method: "DELETE",
});
} catch (error) {
diff --git a/client/src/api/analytics/funnels/useGetFunnel.ts b/client/src/api/analytics/funnels/useGetFunnel.ts
index 6370cb972..38a5be54e 100644
--- a/client/src/api/analytics/funnels/useGetFunnel.ts
+++ b/client/src/api/analytics/funnels/useGetFunnel.ts
@@ -57,7 +57,7 @@ export function useGetFunnel(config?: FunnelRequest, debounce?: boolean) {
...configToUse,
};
try {
- const response = await authedFetch<{ data: FunnelResponse[] }>(`/funnel/${site}`, queryParams, {
+ const response = await authedFetch<{ data: FunnelResponse[] }>(`/funnels/analyze/${site}`, queryParams, {
method: "POST",
data: fullConfig,
});
@@ -91,7 +91,7 @@ export function useSaveFunnel() {
const saveResponse = await authedFetch<{
success: boolean;
funnelId: number;
- }>(`/funnel/create/${site}`, undefined, {
+ }>(`/funnels/${site}`, undefined, {
method: "POST",
data: fullConfig,
});
diff --git a/client/src/api/analytics/funnels/useGetFunnelStepSessions.ts b/client/src/api/analytics/funnels/useGetFunnelStepSessions.ts
index 9a1188688..9782934e2 100644
--- a/client/src/api/analytics/funnels/useGetFunnelStepSessions.ts
+++ b/client/src/api/analytics/funnels/useGetFunnelStepSessions.ts
@@ -36,7 +36,7 @@ export function useGetFunnelStepSessions({
queryKey: ["funnel-step-sessions", steps, stepNumber, siteId, timeParams, mode, page, limit, filteredFilters],
queryFn: async () => {
return authedFetch<FunnelStepSessionsResponse>(
- `/funnel/${stepNumber}/sessions/${siteId}`,
+ `/funnels/${stepNumber}/sessions/${siteId}`,
{
...timeParams,
mode,
diff --git a/client/src/api/analytics/goals/useCreateGoal.ts b/client/src/api/analytics/goals/useCreateGoal.ts
index c7b3735e0..6f41e4c11 100644
--- a/client/src/api/analytics/goals/useCreateGoal.ts
+++ b/client/src/api/analytics/goals/useCreateGoal.ts
@@ -24,7 +24,7 @@ export function useCreateGoal() {
return useMutation<CreateGoalResponse, Error, CreateGoalRequest>({
mutationFn: async goalData => {
try {
- return await authedFetch<CreateGoalResponse>("/goal/create", undefined, {
+ return await authedFetch<CreateGoalResponse>(`/goals/${goalData.siteId}`, undefined, {
method: "POST",
data: goalData,
});
diff --git a/client/src/api/analytics/goals/useDeleteGoal.ts b/client/src/api/analytics/goals/useDeleteGoal.ts
index d18695dc2..0bff93dfa 100644
--- a/client/src/api/analytics/goals/useDeleteGoal.ts
+++ b/client/src/api/analytics/goals/useDeleteGoal.ts
@@ -9,7 +9,7 @@ export function useDeleteGoal() {
return useMutation<{ success: boolean }, Error, number>({
mutationFn: async (goalId: number) => {
try {
- return await authedFetch<{ success: boolean }>(`/goal/${goalId}`, undefined, {
+ return await authedFetch<{ success: boolean }>(`/goals/${goalId}/${site}`, undefined, {
method: "DELETE",
});
} catch (error) {
diff --git a/client/src/api/analytics/goals/useUpdateGoal.ts b/client/src/api/analytics/goals/useUpdateGoal.ts
index 4e6a34123..2ef42dc27 100644
--- a/client/src/api/analytics/goals/useUpdateGoal.ts
+++ b/client/src/api/analytics/goals/useUpdateGoal.ts
@@ -27,7 +27,7 @@ export function useUpdateGoal() {
return useMutation<UpdateGoalResponse, Error, UpdateGoalRequest>({
mutationFn: async goalData => {
try {
- return await authedFetch<UpdateGoalResponse>("/goal/update", undefined, {
+ return await authedFetch<UpdateGoalResponse>(`/goals/${goalData.goalId}/${goalData.siteId}`, undefined, {
method: "PUT",
data: goalData,
});
diff --git a/client/src/api/analytics/useGetUserSessions.ts b/client/src/api/analytics/useGetUserSessions.ts
index c9d1627f2..a18064ec9 100644
--- a/client/src/api/analytics/useGetUserSessions.ts
+++ b/client/src/api/analytics/useGetUserSessions.ts
@@ -219,7 +219,7 @@ export function useGetSessionDetailsInfinite(sessionId: string | null) {
queryParams.minutes = minutes;
}
- return authedFetch<APIResponse<SessionPageviewsAndEvents>>(`/session/${sessionId}/${site}`, queryParams);
+ return authedFetch<APIResponse<SessionPageviewsAndEvents>>(`/sessions/${sessionId}/${site}`, queryParams);
},
initialPageParam: 0,
getNextPageParam: lastPage => {
@@ -244,7 +244,7 @@ export function useGetUserSessionCount(userId: string) {
return useQuery<APIResponse<UserSessionCountResponse[]>>({
queryKey: ["user-session-count", userId, site],
queryFn: () => {
- return authedFetch<APIResponse<UserSessionCountResponse[]>>(`/user/session-count/${site}`, {
+ return authedFetch<APIResponse<UserSessionCountResponse[]>>(`/users/session-count/${site}`, {
user_id: userId,
time_zone: timeZone,
});
diff --git a/client/src/api/analytics/userGetInfo.ts b/client/src/api/analytics/userGetInfo.ts
index 21315fcac..2584072dd 100644
--- a/client/src/api/analytics/userGetInfo.ts
+++ b/client/src/api/analytics/userGetInfo.ts
@@ -35,7 +35,7 @@ export function useUserInfo(siteId: number, userId: string) {
return useQuery<UserInfo>({
queryKey: ["user-info", userId, siteId],
queryFn: async () => {
- const response = await authedFetch<{ data: UserInfo }>(`/user/info/${userId}/${siteId}`);
+ const response = await authedFetch<{ data: UserInfo }>(`/users/${userId}/${siteId}`);
return response.data;
},
});
diff --git a/client/src/app/[site]/goals/components/GoalCard.tsx b/client/src/app/[site]/goals/components/GoalCard.tsx
index 8b0723b12..8ff06b396 100644
--- a/client/src/app/[site]/goals/components/GoalCard.tsx
+++ b/client/src/app/[site]/goals/components/GoalCard.tsx
@@ -101,14 +101,14 @@ export default function GoalCard({ goal, siteId }: GoalCardProps) {
<div className="mt-1">
<span className="text-xs text-neutral-500 dark:text-neutral-400 mr-2">Pattern:</span>
- <code className="text-xs bg-neutral-200 dark:bg-neutral-800 px-1 py-0.5 rounded">
+ <code className="text-xs bg-neutral-100 dark:bg-neutral-800 px-1 py-0.5 rounded">
{goal.goalType === "path" ? goal.config.pathPattern : goal.config.eventName}
</code>
{goal.goalType === "event" && goal.config.eventPropertyKey && (
<div className="mt-1 text-xs text-neutral-500 dark:text-neutral-400">
Property:{" "}
- <code className="text-xs bg-neutral-200 dark:bg-neutral-800 px-1 py-0.5 rounded text-neutral-900 dark:text-neutral-100">
+ <code className="text-xs bg-neutral-100 dark:bg-neutral-800 px-1 py-0.5 rounded text-neutral-900 dark:text-neutral-100">
{goal.config.eventPropertyKey}: {String(goal.config.eventPropertyValue)}
</code>
</div>
diff --git a/docs/content/docs/api/stats/funnels.mdx b/docs/content/docs/api/stats/funnels.mdx
index f55403f33..a77702b3d 100644
--- a/docs/content/docs/api/stats/funnels.mdx
+++ b/docs/content/docs/api/stats/funnels.mdx
@@ -18,19 +18,19 @@ See the [API Reference](/docs/api/stats/reference) for authentication, common pa
</a>
<a href="#analyze-funnel" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-blue-500/20 text-blue-600 dark:text-blue-400">POST</span>
- <code className="text-sm">/api/funnel/:site</code>
+ <code className="text-sm">/api/funnels/analyze/:site</code>
</a>
<a href="#get-funnel-step-sessions" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-blue-500/20 text-blue-600 dark:text-blue-400">POST</span>
- <code className="text-sm">/api/funnel/:stepNumber/sessions/:site</code>
+ <code className="text-sm">/api/funnels/:stepNumber/sessions/:site</code>
</a>
<a href="#create-funnel" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-blue-500/20 text-blue-600 dark:text-blue-400">POST</span>
- <code className="text-sm">/api/funnel/create/:site</code>
+ <code className="text-sm">/api/funnels/:site</code>
</a>
<a href="#delete-funnel" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-red-500/20 text-red-600 dark:text-red-400">DELETE</span>
- <code className="text-sm">/api/funnel/:funnelId</code>
+ <code className="text-sm">/api/funnels/:funnelId/:site</code>
</a>
</div>
@@ -169,7 +169,7 @@ data = response.json()
<div>
```
-POST /api/funnel/:site
+POST /api/funnels/analyze/:site
```
Analyzes a funnel and returns step-by-step conversion data. Sessions must complete steps in order (step 2 must occur after step 1, etc.).
@@ -286,7 +286,7 @@ Accepts all [Common Parameters](/docs/api/stats/reference#common-parameters) (ti
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X POST "https://api.rybbit.io/api/funnel/123?start_date=2024-01-01&end_date=2024-01-31" \
+curl -X POST "https://api.rybbit.io/api/funnels/analyze/123?start_date=2024-01-01&end_date=2024-01-31" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
@@ -302,7 +302,7 @@ curl -X POST "https://api.rybbit.io/api/funnel/123?start_date=2024-01-01&end_dat
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/funnel/123?start_date=2024-01-01&end_date=2024-01-31',
+ 'https://api.rybbit.io/api/funnels/analyze/123?start_date=2024-01-01&end_date=2024-01-31',
{
method: 'POST',
headers: {
@@ -328,7 +328,7 @@ const data = await response.json();
import requests
response = requests.post(
- 'https://api.rybbit.io/api/funnel/123',
+ 'https://api.rybbit.io/api/funnels/analyze/123',
params={
'start_date': '2024-01-01',
'end_date': '2024-01-31'
@@ -397,7 +397,7 @@ data = response.json()
<div>
```
-POST /api/funnel/:stepNumber/sessions/:site
+POST /api/funnels/:stepNumber/sessions/:site
```
Returns sessions that either reached or dropped off at a specific funnel step. Useful for analyzing user behavior at each stage.
@@ -473,7 +473,7 @@ Accepts all [Common Parameters](/docs/api/stats/reference#common-parameters) plu
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Get sessions that dropped off at step 2"
-curl -X POST "https://api.rybbit.io/api/funnel/2/sessions/123?mode=dropped&page=1" \
+curl -X POST "https://api.rybbit.io/api/funnels/2/sessions/123?mode=dropped&page=1" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
@@ -488,7 +488,7 @@ curl -X POST "https://api.rybbit.io/api/funnel/2/sessions/123?mode=dropped&page=
<Tab value="JavaScript">
```javascript title="Get sessions that reached step 3"
const response = await fetch(
- 'https://api.rybbit.io/api/funnel/3/sessions/123?mode=reached&page=1',
+ 'https://api.rybbit.io/api/funnels/3/sessions/123?mode=reached&page=1',
{
method: 'POST',
headers: {
@@ -513,7 +513,7 @@ const data = await response.json();
import requests
response = requests.post(
- 'https://api.rybbit.io/api/funnel/2/sessions/123',
+ 'https://api.rybbit.io/api/funnels/2/sessions/123',
params={
'mode': 'dropped',
'page': 1
@@ -569,7 +569,7 @@ data = response.json()
<div>
```
-POST /api/funnel/create/:site
+POST /api/funnels/:site
```
Creates or updates a saved funnel. If `reportId` is provided, updates the existing funnel.
@@ -629,7 +629,7 @@ Creates or updates a saved funnel. If `reportId` is provided, updates the existi
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Create New Funnel"
-curl -X POST "https://api.rybbit.io/api/funnel/create/123" \
+curl -X POST "https://api.rybbit.io/api/funnels/123" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
@@ -646,7 +646,7 @@ curl -X POST "https://api.rybbit.io/api/funnel/create/123" \
<Tab value="JavaScript">
```javascript title="Update Existing Funnel"
const response = await fetch(
- 'https://api.rybbit.io/api/funnel/create/123',
+ 'https://api.rybbit.io/api/funnels/123',
{
method: 'POST',
headers: {
@@ -674,7 +674,7 @@ const data = await response.json();
import requests
response = requests.post(
- 'https://api.rybbit.io/api/funnel/create/123',
+ 'https://api.rybbit.io/api/funnels/123',
json={
'name': 'Onboarding Funnel',
'steps': [
@@ -712,7 +712,7 @@ data = response.json()
<div>
```
-DELETE /api/funnel/:funnelId
+DELETE /api/funnels/:funnelId/:site
```
Deletes a saved funnel. This action cannot be undone.
@@ -726,6 +726,11 @@ Deletes a saved funnel. This action cannot be undone.
type: 'string | number',
required: true,
},
+ site: {
+ description: 'Site ID or site identifier',
+ type: 'string | number',
+ required: true,
+ },
}}
/>
@@ -746,14 +751,14 @@ Deletes a saved funnel. This action cannot be undone.
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X DELETE "https://api.rybbit.io/api/funnel/1" \
+curl -X DELETE "https://api.rybbit.io/api/funnels/1/123" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/funnel/1',
+ 'https://api.rybbit.io/api/funnels/1/123',
{
method: 'DELETE',
headers: {
@@ -770,7 +775,7 @@ const data = await response.json();
import requests
response = requests.delete(
- 'https://api.rybbit.io/api/funnel/1',
+ 'https://api.rybbit.io/api/funnels/1/123',
headers={
'Authorization': 'Bearer your_api_key_here'
}
diff --git a/docs/content/docs/api/stats/goals.mdx b/docs/content/docs/api/stats/goals.mdx
index acfa87e07..64c50243c 100644
--- a/docs/content/docs/api/stats/goals.mdx
+++ b/docs/content/docs/api/stats/goals.mdx
@@ -22,15 +22,15 @@ See the [API Reference](/docs/api/stats/reference) for authentication, common pa
</a>
<a href="#create-goal" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-blue-500/20 text-blue-600 dark:text-blue-400">POST</span>
- <code className="text-sm">/api/goal/create</code>
+ <code className="text-sm">/api/goals/:site</code>
</a>
<a href="#update-goal" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-yellow-500/20 text-yellow-600 dark:text-yellow-400">PUT</span>
- <code className="text-sm">/api/goal/update</code>
+ <code className="text-sm">/api/goals/:goalId/:site</code>
</a>
<a href="#delete-goal" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-red-500/20 text-red-600 dark:text-red-400">DELETE</span>
- <code className="text-sm">/api/goal/:goalId</code>
+ <code className="text-sm">/api/goals/:goalId/:site</code>
</a>
</div>
@@ -454,20 +454,27 @@ data = response.json()
<div>
```
-POST /api/goal/create
+POST /api/goals/:site
```
Creates a new goal for tracking conversions.
-### Request Body
+### Path Parameters
<TypeTable
type={{
- siteId: {
- description: 'Site ID to create the goal for',
- type: 'number',
+ site: {
+ description: 'Site ID or site identifier',
+ type: 'string | number',
required: true,
},
+ }}
+/>
+
+### Request Body
+
+<TypeTable
+ type={{
name: {
description: 'Goal name',
type: 'string',
@@ -543,11 +550,10 @@ Creates a new goal for tracking conversions.
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Path Goal"
-curl -X POST "https://api.rybbit.io/api/goal/create" \
+curl -X POST "https://api.rybbit.io/api/goals/123" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
- "siteId": 123,
"name": "Checkout Complete",
"goalType": "path",
"config": {
@@ -559,7 +565,7 @@ curl -X POST "https://api.rybbit.io/api/goal/create" \
<Tab value="JavaScript">
```javascript title="Event Goal"
const response = await fetch(
- 'https://api.rybbit.io/api/goal/create',
+ 'https://api.rybbit.io/api/goals/123',
{
method: 'POST',
headers: {
@@ -567,7 +573,6 @@ const response = await fetch(
'Content-Type': 'application/json'
},
body: JSON.stringify({
- siteId: 123,
name: 'Purchase Made',
goalType: 'event',
config: {
@@ -587,9 +592,8 @@ const data = await response.json();
import requests
response = requests.post(
- 'https://api.rybbit.io/api/goal/create',
+ 'https://api.rybbit.io/api/goals/123',
json={
- 'siteId': 123,
'name': 'Signup Complete',
'goalType': 'path',
'config': {
@@ -624,25 +628,32 @@ data = response.json()
<div>
```
-PUT /api/goal/update
+PUT /api/goals/:goalId/:site
```
Updates an existing goal.
-### Request Body
+### Path Parameters
<TypeTable
type={{
goalId: {
description: 'ID of the goal to update',
- type: 'number',
+ type: 'string | number',
required: true,
},
- siteId: {
- description: 'Site ID the goal belongs to',
- type: 'number',
+ site: {
+ description: 'Site ID or site identifier',
+ type: 'string | number',
required: true,
},
+ }}
+/>
+
+### Request Body
+
+<TypeTable
+ type={{
name: {
description: 'Updated goal name',
type: 'string',
@@ -683,12 +694,10 @@ Updates an existing goal.
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X PUT "https://api.rybbit.io/api/goal/update" \
+curl -X PUT "https://api.rybbit.io/api/goals/1/123" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
- "goalId": 1,
- "siteId": 123,
"name": "Signup Completed (Updated)",
"goalType": "path",
"config": {
@@ -700,7 +709,7 @@ curl -X PUT "https://api.rybbit.io/api/goal/update" \
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/goal/update',
+ 'https://api.rybbit.io/api/goals/1/123',
{
method: 'PUT',
headers: {
@@ -708,8 +717,6 @@ const response = await fetch(
'Content-Type': 'application/json'
},
body: JSON.stringify({
- goalId: 1,
- siteId: 123,
name: 'Signup Completed (Updated)',
goalType: 'path',
config: {
@@ -727,10 +734,8 @@ const data = await response.json();
import requests
response = requests.put(
- 'https://api.rybbit.io/api/goal/update',
+ 'https://api.rybbit.io/api/goals/1/123',
json={
- 'goalId': 1,
- 'siteId': 123,
'name': 'Signup Completed (Updated)',
'goalType': 'path',
'config': {
@@ -765,7 +770,7 @@ data = response.json()
<div>
```
-DELETE /api/goal/:goalId
+DELETE /api/goals/:goalId/:site
```
Deletes a goal. This action cannot be undone.
@@ -779,6 +784,11 @@ Deletes a goal. This action cannot be undone.
type: 'string | number',
required: true,
},
+ site: {
+ description: 'Site ID or site identifier',
+ type: 'string | number',
+ required: true,
+ },
}}
/>
@@ -799,14 +809,14 @@ Deletes a goal. This action cannot be undone.
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X DELETE "https://api.rybbit.io/api/goal/1" \
+curl -X DELETE "https://api.rybbit.io/api/goals/1/123" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/goal/1',
+ 'https://api.rybbit.io/api/goals/1/123',
{
method: 'DELETE',
headers: {
@@ -823,7 +833,7 @@ const data = await response.json();
import requests
response = requests.delete(
- 'https://api.rybbit.io/api/goal/1',
+ 'https://api.rybbit.io/api/goals/1/123',
headers={
'Authorization': 'Bearer your_api_key_here'
}
diff --git a/docs/content/docs/api/stats/sessions.mdx b/docs/content/docs/api/stats/sessions.mdx
index c8d36fba0..43c139a5e 100644
--- a/docs/content/docs/api/stats/sessions.mdx
+++ b/docs/content/docs/api/stats/sessions.mdx
@@ -18,7 +18,7 @@ See the [API Reference](/docs/api/stats/reference) for authentication, common pa
</a>
<a href="#get-session" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-green-500/20 text-green-600 dark:text-green-400">GET</span>
- <code className="text-sm">/api/session/:sessionId/:site</code>
+ <code className="text-sm">/api/sessions/:sessionId/:site</code>
</a>
<a href="#get-session-locations" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-green-500/20 text-green-600 dark:text-green-400">GET</span>
@@ -277,7 +277,7 @@ data = response.json()
<div>
```
-GET /api/session/:sessionId/:site
+GET /api/sessions/:sessionId/:site
```
Returns detailed information about a specific session including all events and pageviews.
@@ -394,14 +394,14 @@ Returns detailed information about a specific session including all events and p
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X GET "https://api.rybbit.io/api/session/sess_abc123/123?limit=50" \
+curl -X GET "https://api.rybbit.io/api/sessions/sess_abc123/123?limit=50" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/session/sess_abc123/123?limit=50',
+ 'https://api.rybbit.io/api/sessions/sess_abc123/123?limit=50',
{
headers: {
'Authorization': 'Bearer your_api_key_here'
@@ -417,7 +417,7 @@ const data = await response.json();
import requests
response = requests.get(
- 'https://api.rybbit.io/api/session/sess_abc123/123',
+ 'https://api.rybbit.io/api/sessions/sess_abc123/123',
params={'limit': 50},
headers={
'Authorization': 'Bearer your_api_key_here'
diff --git a/docs/content/docs/api/stats/users.mdx b/docs/content/docs/api/stats/users.mdx
index ad38dd30e..997c0d426 100644
--- a/docs/content/docs/api/stats/users.mdx
+++ b/docs/content/docs/api/stats/users.mdx
@@ -18,15 +18,15 @@ See the [API Reference](/docs/api/stats/reference) for authentication, common pa
</a>
<a href="#get-user-sessions" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-green-500/20 text-green-600 dark:text-green-400">GET</span>
- <code className="text-sm">/api/user/:userId/sessions/:site</code>
+ <code className="text-sm">/api/users/:userId/sessions/:site</code>
</a>
<a href="#get-user-session-count" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-green-500/20 text-green-600 dark:text-green-400">GET</span>
- <code className="text-sm">/api/user/session-count/:site</code>
+ <code className="text-sm">/api/users/session-count/:site</code>
</a>
<a href="#get-user-info" className="flex items-center gap-3 p-3 rounded-lg bg-fd-secondary/50 hover:bg-fd-secondary transition-colors no-underline">
<span className="px-2 py-1 text-xs font-bold rounded bg-green-500/20 text-green-600 dark:text-green-400">GET</span>
- <code className="text-sm">/api/user/info/:userId/:site</code>
+ <code className="text-sm">/api/users/:userId/:site</code>
</a>
</div>
@@ -276,7 +276,7 @@ data = response.json()
<div>
```
-GET /api/user/:userId/sessions/:site
+GET /api/users/:userId/sessions/:site
```
Returns all sessions for a specific user, grouped with their pageviews. Useful for viewing a user's browsing history and behavior patterns.
@@ -392,14 +392,14 @@ Accepts all [Common Parameters](/docs/api/stats/reference#common-parameters) (ti
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X GET "https://api.rybbit.io/api/user/abc123def456/sessions/123?start_date=2024-01-01&end_date=2024-01-31" \
+curl -X GET "https://api.rybbit.io/api/users/abc123def456/sessions/123?start_date=2024-01-01&end_date=2024-01-31" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/user/abc123def456/sessions/123?start_date=2024-01-01&end_date=2024-01-31',
+ 'https://api.rybbit.io/api/users/abc123def456/sessions/123?start_date=2024-01-01&end_date=2024-01-31',
{
headers: {
'Authorization': 'Bearer your_api_key_here'
@@ -415,7 +415,7 @@ const data = await response.json();
import requests
response = requests.get(
- 'https://api.rybbit.io/api/user/abc123def456/sessions/123',
+ 'https://api.rybbit.io/api/users/abc123def456/sessions/123',
params={
'start_date': '2024-01-01',
'end_date': '2024-01-31'
@@ -481,7 +481,7 @@ data = response.json()
<div>
```
-GET /api/user/session-count/:site
+GET /api/users/session-count/:site
```
Returns the number of sessions per day for a specific user. Useful for visualizing user engagement over time.
@@ -549,14 +549,14 @@ Returns the number of sessions per day for a specific user. Useful for visualizi
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X GET "https://api.rybbit.io/api/user/session-count/123?user_id=abc123def456&time_zone=America/New_York" \
+curl -X GET "https://api.rybbit.io/api/users/session-count/123?user_id=abc123def456&time_zone=America/New_York" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/user/session-count/123?user_id=abc123def456&time_zone=America/New_York',
+ 'https://api.rybbit.io/api/users/session-count/123?user_id=abc123def456&time_zone=America/New_York',
{
headers: {
'Authorization': 'Bearer your_api_key_here'
@@ -572,7 +572,7 @@ const data = await response.json();
import requests
response = requests.get(
- 'https://api.rybbit.io/api/user/session-count/123',
+ 'https://api.rybbit.io/api/users/session-count/123',
params={
'user_id': 'abc123def456',
'time_zone': 'America/New_York'
@@ -621,7 +621,7 @@ data = response.json()
<div>
```
-GET /api/user/info/:userId/:site
+GET /api/users/:userId/:site
```
Returns detailed information about a specific user, including their profile traits and linked devices.
@@ -769,14 +769,14 @@ Returns detailed information about a specific user, including their profile trai
<Tabs items={['cURL', 'JavaScript', 'Python']}>
<Tab value="cURL">
```bash title="Request"
-curl -X GET "https://api.rybbit.io/api/user/info/[email protected]/123" \
+curl -X GET "https://api.rybbit.io/api/users/[email protected]/123" \
-H "Authorization: Bearer your_api_key_here"
```
</Tab>
<Tab value="JavaScript">
```javascript title="Request"
const response = await fetch(
- 'https://api.rybbit.io/api/user/info/[email protected]/123',
+ 'https://api.rybbit.io/api/users/[email protected]/123',
{
headers: {
'Authorization': 'Bearer your_api_key_here'
@@ -792,7 +792,7 @@ const data = await response.json();
import requests
response = requests.get(
- 'https://api.rybbit.io/api/user/info/[email protected]/123',
+ 'https://api.rybbit.io/api/users/[email protected]/123',
headers={
'Authorization': 'Bearer your_api_key_here'
}
diff --git a/server/src/index.ts b/server/src/index.ts
index be249974b..ef5c155a8 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -236,30 +236,19 @@ const ANALYTICS_ROUTES = [
"/api/site-has-data/",
"/api/site-is-public/",
"/api/sessions/",
- "/api/session/",
"/api/users/",
- "/api/user/info/",
- "/api/user/session-count/",
"/api/session-locations/",
"/api/funnels/",
- "/api/funnel/",
- "/api/funnel/:stepNumber/sessions/",
"/api/journeys/",
"/api/goals/",
- "/api/goal/",
- "/api/goals/:goalId/sessions/",
- "/api/analytics/events/names/",
- "/api/analytics/events/properties/",
"/api/events/",
"/api/events/outbound/",
"/api/get-site/",
"/api/performance/overview/",
"/api/performance/time-series/",
- "/api/performance/by-path/",
"/api/performance/by-dimension/",
"/api/error-names/",
"/api/error-events/",
- "/api/error-bucketed/",
"/api/session-replay/",
"/api/gsc/data/",
];
@@ -343,24 +332,24 @@ server.get("/api/retention/:site", getRetention);
server.get("/api/site-has-data/:site", getSiteHasData);
server.get("/api/site-is-public/:site", getSiteIsPublic);
server.get("/api/sessions/:site", getSessions);
-server.get("/api/session/:sessionId/:site", getSession);
+server.get("/api/sessions/:sessionId/:site", getSession);
server.get("/api/events/:site", getEvents);
server.get("/api/users/:site", getUsers);
-server.get("/api/user/:userId/sessions/:site", getUserSessions);
-server.get("/api/user/session-count/:site", getUserSessionCount);
-server.get("/api/user/info/:userId/:site", getUserInfo);
+server.get("/api/users/:userId/sessions/:site", getUserSessions);
+server.get("/api/users/session-count/:site", getUserSessionCount);
+server.get("/api/users/:userId/:site", getUserInfo);
server.get("/api/session-locations/:site", getSessionLocations);
server.get("/api/funnels/:site", getFunnels);
server.get("/api/journeys/:site", getJourneys);
-server.post("/api/funnel/:site", getFunnel);
-server.post("/api/funnel/:stepNumber/sessions/:site", getFunnelStepSessions);
-server.post("/api/funnel/create/:site", createFunnel);
-server.delete("/api/funnel/:funnelId", deleteFunnel);
+server.post("/api/funnels/analyze/:site", getFunnel);
+server.post("/api/funnels/:stepNumber/sessions/:site", getFunnelStepSessions);
+server.post("/api/funnels/:site", createFunnel);
+server.delete("/api/funnels/:funnelId/:site", deleteFunnel);
server.get("/api/goals/:site", getGoals);
server.get("/api/goals/:goalId/sessions/:site", getGoalSessions);
-server.post("/api/goal/create", createGoal);
-server.delete("/api/goal/:goalId", deleteGoal);
-server.put("/api/goal/update", updateGoal);
+server.post("/api/goals/:site", createGoal);
+server.delete("/api/goals/:goalId/:site", deleteGoal);
+server.put("/api/goals/:goalId/:site", updateGoal);
server.get("/api/events/names/:site", getEventNames);
server.get("/api/events/properties/:site", getEventProperties);
server.get("/api/events/outbound/:site", getOutboundLinks);