I tried using this REST API.
>Jira 9.16.0
The API I'm using only allows prefix-based search for projects. Are there any APIs that support partial or fuzzy matching instead?
Hi, @RUI HAN
The REST API doesn't have built-in functionality for this, and there are no known hidden methods to achieve it directly. However, you can use a workaround: retrieve all projects via the API and then search through the resulting list to find the ones you need.
Only self-made script.I have python script, but you can make Scriptrunner or something else
import requests# ==== CONFIGURATION ====JIRA_URL = "https://your-jira-server.com"USERNAME = "your-username"API_TOKEN = "your-api-token-or-password" # For Server/DC you can also use your passwordSEARCH_TERM = "test" # <- Enter the keyword to search for# ==== AUTHENTICATION ====auth = (USERNAME, API_TOKEN)headers = {"Accept": "application/json"}# ==== FETCH ALL PROJECTS WITH PAGINATION ====def get_all_projects():projects = []start_at = 0max_results = 50 # Page sizewhile True:url = f"{JIRA_URL}/rest/api/2/project/search?startAt={start_at}&maxResults={max_results}"response = requests.get(url, headers=headers, auth=auth)response.raise_for_status()data = response.json()projects.extend(data.get("values", []))if data.get("isLast", True):breakstart_at += max_resultsreturn projects# ==== PERFORM FUZZY (PARTIAL) SEARCH ====def fuzzy_search_projects(projects, query):query_lower = query.lower()return [p for p in projectsif query_lower in p["key"].lower() or query_lower in p["name"].lower()]# ==== MAIN EXECUTION ====if __name__ == "__main__":all_projects = get_all_projects()matched = fuzzy_search_projects(all_projects, SEARCH_TERM)print(f"Found {len(matched)} project(s) matching '{SEARCH_TERM}':")for project in matched:print(f"- {project['key']}: {project['name']}")
It looks like you're new here. Sign in or register to get started.