A shared tag with AI prompts and code snippets
From workspace: Replit
Team: AI Prompts
Total snippets: 7
7 snippets
Query weather data using requests and print the current temp.
import requests res = requests.get('https://api.weatherapi.com/v1/current.json', params={ 'key': 'your_api_key', 'q': 'Lisbon' }) data = res.json() print("Temp (°C):", data['current']['temp_c'])
Send a GET request with a bearer token in Axios.
import axios from 'axios'; const token = 'your_api_token_here'; const res = await axios.get('https://api.example.com/data', { headers: { Authorization: `Bearer ${token}` } }); console.log(res.data);
Create an Express route to receive and log incoming webhooks.
app.post('/webhook', express.json(), (req, res) => { const event = req.body; console.log('Webhook event received:', event.type); res.sendStatus(200); });
Send a POST request with a JSON payload using the requests library.
import requests payload = {'email': 'test@example.com', 'password': '1234'} res = requests.post('https://api.example.com/login', json=payload) print(res.status_code, res.json())
Use Curl to make a POST request to OpenAI's chat completion API.
curl https://api.openai.com/v1/chat/completions \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4", "messages": [{"role":"user", "content":"Hello!"}] }'
Query all rows from the 'profiles' table using Supabase client.
import { createClient } from '@supabase/supabase-js'; const supabase = createClient('https://xyz.supabase.co', 'public-anon-key'); const { data, error } = await supabase.from('profiles').select('*'); console.log(data);
Use Axios to fetch and log data from a REST API endpoint.
import axios from 'axios'; async function getUsers() { try { const response = await axios.get('https://api.example.com/users'); console.log(response.data); } catch (error) { console.error('API error:', error.message); } }