Fix Lorcana API search syntax - use correct endpoints and search parameters

This commit is contained in:
Randall Stillwell 2025-07-23 06:34:21 -05:00
parent 0a09b333c4
commit dbb0353def
2 changed files with 7 additions and 5 deletions

View file

@ -15,9 +15,10 @@ export async function GET(request) {
if (api === 'lorcana') {
// Lorcana API - using correct endpoint from docs
if (search) {
url = `https://api.lorcana-api.com/cards?search=${encodeURIComponent(search)}`;
// Use the correct search parameter format for Lorcana API
url = `https://api.lorcana-api.com/cards/fetch?search=name~${encodeURIComponent(search)}`;
} else {
url = `https://api.lorcana-api.com/cards?limit=${limit}`;
url = `https://api.lorcana-api.com/cards/fetch?pagesize=${limit}`;
}
headers = {
'Accept': 'application/json',

View file

@ -331,7 +331,8 @@ export const lorcanaService = {
// Fallback to direct APIs
try {
const response = await fetch(`${LORCANA_API_BASE_URL}/cards?search=${encodeURIComponent(query)}`);
// Use correct search syntax for Lorcana API
const response = await fetch(`${LORCANA_API_BASE_URL}/cards/fetch?search=name~${encodeURIComponent(query)}`);
if (response.ok) {
const data = await response.json();
@ -472,7 +473,7 @@ export const lorcanaService = {
// Fallback to direct Lorcana API
try {
const response = await fetch(`${LORCANA_API_BASE_URL}/cards?search=${encodeURIComponent(name)}`);
const response = await fetch(`${LORCANA_API_BASE_URL}/cards/fetch?search=name~${encodeURIComponent(name)}`);
if (response.ok) {
const data = await response.json();
@ -619,7 +620,7 @@ export const lorcanaService = {
// Fallback to direct Lorcana API
try {
const response = await fetch(`${LORCANA_API_BASE_URL}/cards?limit=${count}`);
const response = await fetch(`${LORCANA_API_BASE_URL}/cards/fetch?pagesize=${count}`);
if (response.ok) {
const data = await response.json();