API Usage

Interacting with the Fraud Detection API

In this guide, we'll show you how to interact with our Fraud Detection API using Python, JavaScript (JSX), and a cURL command.

Prerequisites

Before you start, ensure that you have the following:

  • API Key: You must have an API key to access our Fraud Detection API. Replace YOUR_API_KEY in the examples with your actual API key.

Python

import requests
 
# Define the API endpoint and API key
url = 'http://localhost:3000/api/transaction'
headers = {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
}
 
# Define the transaction details in a dictionary
transaction_data = {
   " email:" "client@example.com,  // registered email address 
    "product": "Rolex Watch",  // can be a product or service
    "amount": "2500",
    "location": "Los Angeles",
    "time": "2023-12-10 14:20:00",
    "customerProfile": "New customer",
    "onlinePurchase": "Yes",
    "paymentMethod": "Credit card",
    "shippingAddress": "456 Elm St, Los Angeles, CA 90001",
    "billingAddress": "1888 SW firebase ave, Miami, FL 33155",
    "customerEmail": "peterwilson@gmail.com",
    "customerName": "Alice Smith",
     "isVPN": "Yes"
}
 
# Send a POST request to the API
response = requests.post(url, headers=headers, json=transaction_data)
 
# Print the response
print("Response:", response.json())
 

Making an API Request in JavaScript (JSX)

In this guide, we'll demonstrate how to make an API request in JavaScript (JSX) using the fetch method.


const apiUrl = 'http://localhost:3000/api/transaction';
const apiKey = 'YOUR_API_KEY';

// Define the transaction details
const transactionData = {
  email: "client@example.com,  // registered email address 
  product: "Rolex Watch",  // can be a product or service
  amount: "2500",
  location: "Los Angeles",
  time: "2023-12-10 14:20:00",
  customerProfile: "New customer",
  onlinePurchase: "Yes",
  paymentMethod: "Credit card",
  shippingAddress: "456 Elm St, Los Angeles, CA 90001",
  billingAddress: "1888 SW firebase ave, Miami, FL 33155",
  customerEmail: "peterwilson@gmail.com",
  customerName: "Alice Smith",
   "isVPN": "Yes"
};

// Create the request
fetch(apiUrl, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': apiKey
  },
  body: JSON.stringify(transactionData)
})
  .then(response => response.json())
  .then(data => {
    console.log('Response:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });

Making an API Request with cURL

In this guide, we'll demonstrate how to make an API request using the cURL command-line tool.

To make an API request, you can use the following cURL command:

curl -X POST http://localhost:3000/api/transaction \
-H "Content-Type: application/json" \
-H "x-api-key: fc9c4e0a-2cde-47f0-81ae-da31a6af52cb" \
-d '{
    "email": "client@example.com",
    "product": "Rolex Watch",
    "amount": "1150",
    "location": "Russia",
    "time": "2023-12-15 21:20:00",
    "customerProfile": "New customer",
    "onlinePurchase": "Yes",
    "paymentMethod": "Debit card",
    "shippingAddress": "789 Maple St, Chicago, IL 60601",
    "billingAddress": "456 Pine St, Los Angeles, CA 90001",
    "customerEmail": "peterwilson@gmail.com",
    "customerName": "Alice Smith",
     "isVPN": "Yes"
}'