Make a function to perform the search

Since we have the needed packages imported and the API configuration variables set, we can now start to do things with them. First let's define a function that will perform the search.

import requests
import json

# Your API configuration
API_KEY = "YOUR_API_KEY_HERE"  # Replace with your actual key
BASE_URL = "https://api.simpler.grants.gov"

# The function that will contain search logic
def search_opportunities(search_term=""):
    """Search for grant opportunities"""

The default search_term="" means “no keyword filter.”

Last updated

Was this helpful?