### Quick Start Example Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Quick start example: initialize the client with your API key, set query parameters (brand and count), execute the API call, and print the result. Errors are caught and printed. ```python from apiverve_cardgenerator.apiClient import CardgeneratorAPIClient # Initialize the client with your APIVerve API key api = CardgeneratorAPIClient("[YOUR_API_KEY]") query = { "brand": "visa", "count": 1 } try: # Make the API call result = api.execute(query) # Print the result print(result) except Exception as e: print(f"Error: {e}") ``` -------------------------------- ### Setup Client Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Setup example: import the client module and initialize the client with your APIVerve API key. ```python # Import the client module from apiverve_cardgenerator.apiClient import CardgeneratorAPIClient # Initialize the client with your APIVerve API key api = CardgeneratorAPIClient("[YOUR_API_KEY]") ``` -------------------------------- ### Install dependencies with dart pub get or flutter pub get Source: https://github.com/apiverve/cardgenerator-api/blob/main/dart/README.md Installs the package dependencies. Use dart pub get for Dart projects or flutter pub get for Flutter projects. ```bash dart pub get # or for Flutter flutter pub get ``` -------------------------------- ### Install with pip Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Install the Card Generator API wrapper using pip. ```bash pip install apiverve-cardgenerator ``` -------------------------------- ### Install with yarn Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Installs the package using yarn. ```shell yarn add @apiverve/cardgenerator ``` -------------------------------- ### Install with pip3 Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Install the Card Generator API wrapper using pip3. ```bash pip3 install apiverve-cardgenerator ``` -------------------------------- ### Install with NuGet CLI: nuget install APIVerve.API.TestCardGenerator Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Use this command in the NuGet CLI to install the APIVerve.API.TestCardGenerator package. ```bash nuget install APIVerve.API.TestCardGenerator ``` -------------------------------- ### Setup API client Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Initializes the API client with your API key. Replace [YOUR_API_KEY] with your actual key obtained from apiverve.com. ```javascript const cardgeneratorAPI = require('@apiverve/cardgenerator'); const api = new cardgeneratorAPI({ api_key: '[YOUR_API_KEY]' }); ``` -------------------------------- ### Set up Python package Source: https://github.com/apiverve/cardgenerator-api/blob/main/CONTRIBUTING.md Commands to install dependencies and run tests for the Python package. Run from the repository root. ```bash cd python/ pip install -r requirements.txt python -m pytest ``` -------------------------------- ### Install the Card Generator API Go client Source: https://github.com/apiverve/cardgenerator-api/blob/main/go/README.md Installs the Card Generator API Go client package. Run this command in your Go module directory. ```bash go get github.com/apiverve/cardgenerator-api/go ``` -------------------------------- ### Set up CocoaPods package Source: https://github.com/apiverve/cardgenerator-api/blob/main/CONTRIBUTING.md Commands to install CocoaPods dependencies and a comment indicating tests are run in Xcode. Run from the repository root. ```bash cd cocoapods/ pod install # Run tests in Xcode ``` -------------------------------- ### Install with Package Manager Console: Install-Package APIVerve.API.TestCardGenerator Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Use this command in the Package Manager Console to install the APIVerve.API.TestCardGenerator package. ```powershell Install-Package APIVerve.API.TestCardGenerator ``` -------------------------------- ### Install Card Generator PHP package Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Installs the Card Generator PHP package using Composer. ```bash composer require apiverve/cardgenerator ``` -------------------------------- ### Install Card Generator Ruby gem Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Installs the Card Generator Ruby gem via RubyGems. ```bash gem install apiverve_cardgenerator ``` -------------------------------- ### Install Card Generator NPM package Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Installs the official Card Generator JavaScript/Node.js package via npm. ```bash npm install @apiverve/cardgenerator ``` -------------------------------- ### Install with .NET CLI: dotnet add package APIVerve.API.TestCardGenerator Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Use this command in the .NET CLI to add the APIVerve.API.TestCardGenerator package to your project. ```bash dotnet add package APIVerve.API.TestCardGenerator ``` -------------------------------- ### C# API Call Source: https://github.com/apiverve/cardgenerator-api/blob/main/examples/README.md C# example using HttpClient to call the Test Card Generator API. Replace YOUR_API_KEY with your actual key. The response is read as a string. ```csharp // See: ./csharp/basic.cs var client = new HttpClient(); client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY"); var response = await client.GetAsync("https://api.apiverve.com/v1/cardgenerator"); var data = await response.Content.ReadAsStringAsync(); ``` -------------------------------- ### Basic Usage of Card Generator Client Source: https://github.com/apiverve/cardgenerator-api/blob/main/php/README.md Initialize the client with your API key and execute a request to generate test card numbers. The example uses brand 'visa', count 1, and includeAvatar true. ```php execute([ 'brand' => 'visa', 'count' => 1, 'includeAvatar' => true ]); // Print the response print_r($response); ``` -------------------------------- ### Quick Start: Generate test card numbers with TestCardGeneratorAPIClient Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Initializes the TestCardGeneratorAPIClient with your API key, sets query options for brand, count, and avatar inclusion, then executes the request and prints the response or error. ```csharp using System; using APIVerve.API.TestCardGenerator; class Program { static async Task Main(string[] args) { // Initialize the API client var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; // Make the API call try { var response = await apiClient.ExecuteAsync(queryOptions); if (response.Error != null) { Console.WriteLine($"API Error: {response.Error}"); } else { Console.WriteLine("Success!"); // Access response data using the strongly-typed ResponseObj properties Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented)); } } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); } } } ``` -------------------------------- ### Using Promises with api.execute Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Uses a promise to handle the API response. The query object is the same as in the callback example. The promise resolves with the data or rejects with an error. ```javascript var query = { brand: "visa", count: 1, includeAvatar: false }; api.execute(query) .then(data => { console.log(data); }) .catch(error => { console.error(error); }); ``` -------------------------------- ### Example Response from Card Generator API Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Shows the JSON response structure returned by the API, including status, error, and data with generated card details. ```json { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 798, "issuer": "BANCO BILBAO VIZCAYA ARGENTARIA PARAGUAY, S.A.", "id": "c5805305-62df-43d8-bdfd-ac72b459cc64", "number": "4236228422790803", "expiration": "05/2030", "brand": "visa", "number_alt": { "masked": "************0803", "unmasked": "4236 2284 2279 0803", "last4": "0803" } }, { "cvv": 284, "issuer": "IDBI BANK, LTD.", "id": "6a9d0686-6390-40d3-81a9-83cb7da1e1e1", "number": "4581393917480061", "expiration": "05/2030", "brand": "visa", "number_alt": { "masked": "************0061", "unmasked": "4581 3939 1748 0061", "last4": "0061" } }, { "cvv": 184, "issuer": "CREDIT SAISON CO., LTD.", "id": "97e9a5cb-0bd1-46d5-b486-61caf7692155", "number": "4541313270704781", "expiration": "05/2030", "brand": "visa", "number_alt": { "masked": "************4781", "unmasked": "4541 3132 7070 4781", "last4": "4781" } }, { "cvv": 649, "issuer": "CARD SERVICES FOR CREDIT UNIONS, INC.", "id": "013f5e59-5c1a-4c92-a2a7-171384de2416", "number": "4148851836478785", "expiration": "05/2030", "brand": "visa", "number_alt": { "masked": "************8785", "unmasked": "4148 8518 3647 8785", "last4": "8785" } }, { "cvv": 161, "issuer": "JPMORGAN CHASE BANK, N.A.", "id": "d4cf0704-7c48-4221-bcae-53c676261487", "number": "4867963822584424", "expiration": "05/2030", "brand": "visa", "number_alt": { "masked": "************4424", "unmasked": "4867 9638 2258 4424", "last4": "4424" } } ], "owner": { "name": "Herman Gulgowski", "address": { "street": "3659 Konopelski Coves", "city": "Schmittburgh", "state": "Utah", "zipCode": "01681-6561" } } } } ``` -------------------------------- ### Install Card Generator Dart package Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Adds the Card Generator Dart package to your pubspec.dart dependencies. ```bash dart pub add apiverve_cardgenerator ``` -------------------------------- ### Install Card Generator Android package Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Adds the Card Generator Android package as a Gradle dependency via JitPack. ```gradle implementation 'com.github.apiverve:cardgenerator-api:1.0.0' ``` -------------------------------- ### Python API Call Source: https://github.com/apiverve/cardgenerator-api/blob/main/examples/README.md Python example using the requests library to call the Test Card Generator API. Replace YOUR_API_KEY with your actual key. The response is parsed as JSON. ```python # See: ./python/basic.py import requests response = requests.get('https://api.apiverve.com/v1/cardgenerator', headers={'x-api-key': 'YOUR_API_KEY'}) data = response.json() ``` -------------------------------- ### Example API Response: Test Card Generator Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Sample response from the Test Card Generator API showing five generated Visa cards with masked and unmasked number variations and owner details. ```json { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 175, "issuer": "SOUTHEAST F.C.U.", "id": "0faca124-9a33-4ac6-a3df-8bf103025779", "number": "4750377207233152", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************3152", "unmasked": "4750 3772 0723 3152", "last4": "3152" } }, { "cvv": 129, "issuer": "U.S. BANK, N.A.", "id": "0d074efe-69e2-4e30-b49a-4cead1ea8411", "number": "4431387818727358", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************7358", "unmasked": "4431 3878 1872 7358", "last4": "7358" } }, { "cvv": 249, "issuer": "AUGUSTA VAH F.C.U.", "id": "2f01f458-7422-400e-bbcf-41364564193b", "number": "4425919427248836", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************8836", "unmasked": "4425 9194 2724 8836", "last4": "8836" } }, { "cvv": 892, "issuer": "CITIZENS SECURITY BANK AND TRUST COMPANY", "id": "d311e9d0-f410-4f75-a21f-f14125c88cbb", "number": "4127737519045634", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************5634", "unmasked": "4127 7375 1904 5634", "last4": "5634" } }, { "cvv": 524, "issuer": "CREDIT LIBANAIS S.A.L.", "id": "64113f4d-c625-43d2-9d82-04f220c9e26f", "number": "4741441509416816", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************6816", "unmasked": "4741 4415 0941 6816", "last4": "6816" } } ], "owner": { "name": "Benny Swaniawski", "address": { "street": "007 Nelson Mountains", "city": "Margueriteton", "state": "Washington", "zipCode": "39956-7950" }, "avatar": "https://storage.googleapis.com/apiverve/APIResources/faces/Male/30-40/12345678.jpg?X-Goog-Signature=..." } } } ``` -------------------------------- ### JavaScript (Node.js) API Call Source: https://github.com/apiverve/cardgenerator-api/blob/main/examples/README.md Node.js example for calling the Test Card Generator API. Requires an API key; replace YOUR_API_KEY with your actual key. The response is parsed as JSON. ```javascript // See: ./javascript/basic.js const response = await fetch('https://api.apiverve.com/v1/cardgenerator', { headers: { 'x-api-key': 'YOUR_API_KEY' } }); const data = await response.json(); ``` -------------------------------- ### Call Card Generator API with cURL Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Uses cURL to make a GET request to the Card Generator API with the brand parameter and your API key. The response is printed to stdout. ```bash curl -X GET "https://api.apiverve.com/v1/cardgenerator?brand=visa" \ -H "x-api-key: YOUR_API_KEY_HERE" ``` -------------------------------- ### Call Card Generator API with JavaScript Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Sends a GET request to the Card Generator API with the brand parameter set to 'visa' and your API key. Logs the JSON response or an error if the request fails. ```javascript async function callTestCardGeneratorAPI() { try { const params = new URLSearchParams({ brand: 'visa' }); const response = await fetch(`https://api.apiverve.com/v1/cardgenerator?${params}`, { method: 'GET', headers: { 'x-api-key': 'YOUR_API_KEY_HERE' } }); const data = await response.json(); console.log(data); } catch (error) { console.error('Error:', error); } } callTestCardGeneratorAPI(); ``` -------------------------------- ### Set up NuGet package Source: https://github.com/apiverve/cardgenerator-api/blob/main/CONTRIBUTING.md Commands to restore, build, and test the NuGet package. Run from the repository root. ```bash cd nuget/ dotnet restore dotnet build dotnet test ``` -------------------------------- ### Set up NPM package Source: https://github.com/apiverve/cardgenerator-api/blob/main/CONTRIBUTING.md Commands to set up and test the NPM package. Run from the repository root after cloning. ```bash cd npm/ npm install npm test ``` -------------------------------- ### Set up Android package Source: https://github.com/apiverve/cardgenerator-api/blob/main/CONTRIBUTING.md Commands to build and test the Android package using Gradle. Run from the repository root. ```bash cd android/ gradle build gradle test ``` -------------------------------- ### Initialize CardgeneratorClient and execute request Source: https://github.com/apiverve/cardgenerator-api/blob/main/dart/README.md Imports the package, creates a CardgeneratorClient with your API key, and executes a request with a brand parameter. The response is returned asynchronously. ```dart import 'package:apiverve_cardgenerator/apiverve_cardgenerator.dart'; void main() async { final client = CardgeneratorClient('YOUR_API_KEY'); try { final response = await client.execute({ 'brand': 'visa', }); print(response); } catch (e) { print('Error: $e'); } } ``` -------------------------------- ### Generate test card numbers with the Card Generator API Go client Source: https://github.com/apiverve/cardgenerator-api/blob/main/go/README.md Shows how to create a client, set parameters for generating test card numbers, and execute the request. Replace YOUR_API_KEY with your actual API key. The response contains status and data fields. ```go package main import ( "fmt" "log" "github.com/apiverve/cardgenerator-api/go" ) func main() { // Create a new client client := cardgenerator.NewClient("YOUR_API_KEY") // Set up parameters params := map[string]interface{}{ "brand": "visa", "count": 1 } // Make the request response, err := client.Execute(params) if err != nil { log.Fatal(err) } fmt.Printf("Status: %s\n", response.Status) fmt.Printf("Data: %+v\n", response.Data) } ``` -------------------------------- ### Using Context Manager for Automatic Cleanup Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Shows the recommended way to use the client with a context manager, ensuring the session is automatically closed after the block. Wrap the API call in a try/except to handle errors. ```python from apiverve_cardgenerator.apiClient import CardgeneratorAPIClient, CardgeneratorAPIClientError query = { "brand": "visa", "count": 1 } # Using context manager ensures proper cleanup with CardgeneratorAPIClient("[YOUR_API_KEY]") as api: try: result = api.execute(query) print(result) except CardgeneratorAPIClientError as e: print(f"Error: {e.message}") # Session is automatically closed here ``` -------------------------------- ### Create TestCardGenerator API client instance Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Creates an instance of the TestCardGeneratorAPIClient by passing your API key. Replace [YOUR_API_KEY] with your actual API key. ```csharp // Create an instance of the API client var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); ``` -------------------------------- ### Using APIResponse methods Source: https://github.com/apiverve/cardgenerator-api/blob/main/android/README.md Demonstrates the methods available on the APIResponse object to check status, retrieve data, and access the raw response. ```java APIResponse response = client.execute(params); // Check status boolean success = response.isSuccess(); boolean error = response.isError(); // Get data String status = response.getStatus(); String errorMsg = response.getError(); JSONObject data = response.getData(); int code = response.getCode(); // Get raw response JSONObject raw = response.getRawResponse(); ``` -------------------------------- ### Basic Usage with Async/Await Pattern Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Uses the async/await pattern to execute a card generation query. The response is checked for errors and serialized to JSON with Newtonsoft.Json. ```csharp using System; using System.Threading.Tasks; using APIVerve.API.TestCardGenerator; public class Example { public static async Task Main(string[] args) { var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; var response = await apiClient.ExecuteAsync(queryOptions); if (response.Error != null) { Console.WriteLine($"Error: {response.Error}"); } else { Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented)); } } } ``````json { ``` -------------------------------- ### Configure retry behavior in C# Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Shows how to set maximum retries and retry delay using SetMaxRetries and SetRetryDelay. Default retries are 0 with max 3, and default delay is 1000ms. ```csharp var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); // Set retry options apiClient.SetMaxRetries(3); // Retry up to 3 times (default: 0, max: 3) apiClient.SetRetryDelay(1500); // Wait 1.5 seconds between retries (default: 1000ms) var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; var response = await apiClient.ExecuteAsync(queryOptions); ``` -------------------------------- ### Enable Debug Mode for Card Generator Client Source: https://github.com/apiverve/cardgenerator-api/blob/main/php/README.md Instantiate the Client with the 'debug' parameter set to true to enable debug logging. ```php // Enable debug logging $client = new Client( apiKey: 'YOUR_API_KEY', debug: true ); ``` -------------------------------- ### Execute Request and Print Result Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Makes a request to the API using the defined query and prints the result. ```python # Make a request to the API result = api.execute(query) # Print the result print(result) ``` -------------------------------- ### Add JitPack repository to build.gradle Source: https://github.com/apiverve/cardgenerator-api/blob/main/android/README.md Adds the JitPack repository to the root build.gradle file so the SDK can be resolved from JitPack. ```gradle allprojects { repositories { maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Using Async/Await with api.execute Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Uses async/await to make the API request. The function defines a query object and awaits the promise from api.execute, logging the data or catching an error. ```javascript async function makeRequest() { var query = { brand: "visa", count: 1, includeAvatar: false }; try { const data = await api.execute(query); console.log(data); } catch (error) { console.error(error); } } ``` -------------------------------- ### api.execute(query) with async/await Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Executes a card generation request using async/await asynchronous handling. This method returns a promise that can be awaited, simplifying error handling with try/catch blocks. ```APIDOC ## api.execute(query) returns Promise (async/await) ### Description Executes a card generation request using async/await asynchronous handling. The method returns a promise that can be awaited, simplifying error handling with try/catch blocks. ### Method execute ### Parameters #### Query Object - **brand** (string) - Required - The card brand (e.g., "visa"). - **count** (number) - Required - The number of cards to generate. - **includeAvatar** (boolean) - Required - Whether to include an avatar for the card owner. ### Request Example ```javascript async function makeRequest() { var query = { brand: "visa", count: 1, includeAvatar: false }; try { const data = await api.execute(query); console.log(data); } catch (error) { console.error(error); } } ``` ### Response #### Success Response - **status** (string) - The status of the response (e.g., "ok"). - **error** (null) - Always null on success. - **data** (object) - The response data containing generated cards. - **brand** (string) - The card brand. - **count** (number) - The number of cards generated. - **cards** (array) - An array of card objects. - **cvv** (number) - The card CVV. - **issuer** (string) - The card issuer. - **id** (string) - The card ID. - **number** (string) - The card number. - **expiration** (string) - The card expiration date. - **brand** (string) - The card brand. - **number_alt** (object) - Alternative number formats. - **masked** (string) - Masked card number. - **unmasked** (string) - Unmasked card number. - **last4** (string) - Last four digits of the card number. - **owner** (object) - The card owner information. - **name** (string) - The owner's name. - **address** (object) - The owner's address. - **street** (string) - Street address. - **city** (string) - City. - **state** (string) - State. - **zipCode** (string) - Zip code. - **avatar** (string) - URL to the owner's avatar. #### Response Example ```json { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 175, "issuer": "SOUTHEAST F.C.U.", "id": "0faca124-9a33-4ac6-a3df-8bf103025779", "number": "4750377207233152", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************3152", "unmasked": "4750 3772 0723 3152", "last4": "3152" } } ], "owner": { "name": "Benny Swaniawski", "address": { "street": "007 Nelson Mountains", "city": "Margueriteton", "state": "Washington", "zipCode": "39956-7950" }, "avatar": "https://storage.googleapis.com/apiverve/APIResources/faces/Male/30-40/12345678.jpg?X-Goog-Signature=..." } } } ``` ``` -------------------------------- ### Configure retry logic with SetMaxRetries and SetRetryDelay Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Adds retry logic with SetMaxRetries(3) and SetRetryDelay(2000) to automatically retry failed requests up to 3 times with a 2-second delay. The default retry count is 0 and the maximum is 3; use this when you need resilience against transient network failures. ```csharp using System; using System.Threading.Tasks; using APIVerve.API.TestCardGenerator; public class Example { public static async Task Main(string[] args) { var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); // Configure retry behavior (max 3 retries) apiClient.SetMaxRetries(3); // Retry up to 3 times (default: 0, max: 3) apiClient.SetRetryDelay(2000); // Wait 2 seconds between retries var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; try { var response = await apiClient.ExecuteAsync(queryOptions); if (response.Error != null) { Console.WriteLine($"API Error: {response.Error}"); } else { Console.WriteLine("Success!"); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented)); } } catch (Exception ex) { Console.WriteLine($"Failed after retries: {ex.Message}"); } } } ``` -------------------------------- ### api.execute(query, callback) Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Executes a card generation request using callback-based asynchronous handling. This method is called with a query object containing card generation parameters, and a callback that receives an error and the response data. ```APIDOC ## api.execute(query, callback) ### Description Executes a card generation request using callback-based asynchronous handling. The method takes a query object and a callback function invoked with an error and data. ### Method execute ### Parameters #### Query Object - **brand** (string) - Required - The card brand (e.g., "visa"). - **count** (number) - Required - The number of cards to generate. - **includeAvatar** (boolean) - Required - Whether to include an avatar for the card owner. ### Request Example ```javascript var query = { brand: "visa", count: 1, includeAvatar: false }; api.execute(query, function (error, data) { if (error) { return console.error(error); } else { console.log(data); } }); ``` ### Response #### Success Response - **status** (string) - The status of the response (e.g., "ok"). - **error** (null) - Always null on success. - **data** (object) - The response data containing generated cards. - **brand** (string) - The card brand. - **count** (number) - The number of cards generated. - **cards** (array) - An array of card objects. - **cvv** (number) - The card CVV. - **issuer** (string) - The card issuer. - **id** (string) - The card ID. - **number** (string) - The card number. - **expiration** (string) - The card expiration date. - **brand** (string) - The card brand. - **number_alt** (object) - Alternative number formats. - **masked** (string) - Masked card number. - **unmasked** (string) - Unmasked card number. - **last4** (string) - Last four digits of the card number. - **owner** (object) - The card owner information. - **name** (string) - The owner's name. - **address** (object) - The owner's address. - **street** (string) - Street address. - **city** (string) - City. - **state** (string) - State. - **zipCode** (string) - Zip code. - **avatar** (string) - URL to the owner's avatar. #### Response Example ```json { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 175, "issuer": "SOUTHEAST F.C.U.", "id": "0faca124-9a33-4ac6-a3df-8bf103025779", "number": "4750377207233152", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************3152", "unmasked": "4750 3772 0723 3152", "last4": "3152" } } ], "owner": { "name": "Benny Swaniawski", "address": { "street": "007 Nelson Mountains", "city": "Margueriteton", "state": "Washington", "zipCode": "39956-7950" }, "avatar": "https://storage.googleapis.com/apiverve/APIResources/faces/Male/30-40/12345678.jpg?X-Goog-Signature=..." } } } ``` ``` -------------------------------- ### Enable request logging with debug mode and custom logger in C# Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Shows how to enable debug logging by passing isDebug: true to the constructor, or set a custom logger using SetLogger. The logger writes messages with a timestamp. ```csharp var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]", isDebug: true); // Or use a custom logger apiClient.SetLogger(message => { Console.WriteLine($"[LOG] {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {message}"); }); var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; var response = await apiClient.ExecuteAsync(queryOptions); ``` -------------------------------- ### Client::execute Source: https://github.com/apiverve/cardgenerator-api/blob/main/php/README.md Generates a list of test card numbers based on the provided parameters. This is the main method for interacting with the Card Generator API. ```APIDOC ## Client::execute ### Description Generates a list of test card numbers based on the provided parameters. This is the main method for interacting with the Card Generator API. ### Method POST ### Endpoint https://api.apiverve.com/v1/cardgenerator ### Parameters #### Request Body - **brand** (string) - Required - The card brand (e.g., 'visa'). - **count** (integer) - Required - The number of card numbers to generate. - **includeAvatar** (boolean) - Optional - Whether to include an avatar for the card owner. ### Request Example { "brand": "visa", "count": 1, "includeAvatar": true } ### Response #### Success Response (200) - **status** (string) - The status of the request. - **error** (null) - Error message, if any. - **data** (object) - The generated card data. - **brand** (string) - The card brand. - **count** (integer) - The number of cards generated. - **cards** (array) - List of generated cards. - **cvv** (integer) - The CVV code. - **issuer** (string) - The card issuer. - **id** (string) - The card ID. - **number** (string) - The card number. - **expiration** (string) - The expiration date. - **brand** (string) - The card brand. - **number_alt** (object) - Alternative number formats. - **masked** (string) - Masked card number. - **unmasked** (string) - Unmasked card number with spaces. - **last4** (string) - Last 4 digits. - **owner** (object) - The card owner information. - **name** (string) - The owner's name. - **address** (object) - The owner's address. - **street** (string) - Street address. - **city** (string) - City. - **state** (string) - State. - **zipCode** (string) - ZIP code. - **avatar** (string) - URL to the owner's avatar. #### Response Example { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 175, "issuer": "SOUTHEAST F.C.U.", "id": "0faca124-9a33-4ac6-a3df-8bf103025779", "number": "4750377207233152", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************3152", "unmasked": "4750 3772 0723 3152", "last4": "3152" } } ], "owner": { "name": "Benny Swaniawski", "address": { "street": "007 Nelson Mountains", "city": "Margueriteton", "state": "Washington", "zipCode": "39956-7950" }, "avatar": "https://storage.googleapis.com/apiverve/APIResources/faces/Male/30-40/12345678.jpg?X-Goog-Signature=..." } } } ``` -------------------------------- ### Basic usage of CardGeneratorAPIClient Source: https://github.com/apiverve/cardgenerator-api/blob/main/android/README.md Initializes the CardGeneratorAPIClient with your API key, sets query parameters (brand and count), executes the request, and handles success or error responses. ```java import com.apiverve.cardgenerator.CardGeneratorAPIClient; import com.apiverve.cardgenerator.APIResponse; import com.apiverve.cardgenerator.APIException; // Initialize the client CardGeneratorAPIClient client = new CardGeneratorAPIClient("YOUR_API_KEY"); try { // Prepare query parameters Map parameters = new HashMap<>(); parameters.put("brand", "visa"); parameters.put("count", 1); // Execute the request APIResponse response = client.execute(parameters); if (response.isSuccess()) { // Handle successful response JSONObject data = response.getData(); System.out.println("Success: " + data.toString()); } else { // Handle API error System.err.println("API Error: " + response.getError()); } } catch (APIException e) { // Handle exception e.printStackTrace(); } ``` -------------------------------- ### Dispose pattern with using statement in C# Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Shows proper resource cleanup by wrapping the client in a using block. The HttpClient is automatically disposed after the block. ```csharp var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; using (var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]")) { var response = await apiClient.ExecuteAsync(queryOptions); Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented)); } // HttpClient is automatically disposed here ``` -------------------------------- ### Add and remove custom headers in C# Source: https://github.com/apiverve/cardgenerator-api/blob/main/nuget/Readme.md Shows how to add custom headers to requests, then remove a specific header or clear all custom headers. Uses AddCustomHeader, RemoveCustomHeader, and ClearCustomHeaders methods. ```csharp var apiClient = new TestCardGeneratorAPIClient("[YOUR_API_KEY]"); // Add custom headers apiClient.AddCustomHeader("X-Custom-Header", "custom-value"); apiClient.AddCustomHeader("X-Request-ID", Guid.NewGuid().ToString()); var queryOptions = new TestCardGeneratorQueryOptions { Brand = "visa", Count = 1, IncludeAvatar = true }; var response = await apiClient.ExecuteAsync(queryOptions); // Remove a header apiClient.RemoveCustomHeader("X-Custom-Header"); // Clear all custom headers apiClient.ClearCustomHeaders(); ``` -------------------------------- ### Handling Specific Error Types with Status Codes Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Demonstrates checking the response status and handling specific HTTP status codes (401, 429, 5xx) in the exception handler. Also includes a generic exception handler for unexpected errors. ```python from apiverve_cardgenerator.apiClient import CardgeneratorAPIClient, CardgeneratorAPIClientError api = CardgeneratorAPIClient("[YOUR_API_KEY]") query = { "brand": "visa", "count": 1 } try: result = api.execute(query) # Check for successful response if result.get('status') == 'success': print("Request successful!") print(result.get('data')) else: print(f"API returned an error: {result.get('error')}") except CardgeneratorAPIClientError as e: # Handle API client errors if e.status_code == 401: print("Unauthorized: Invalid API key") elif e.status_code == 429: print("Rate limit exceeded") elif e.status_code >= 500: print("Server error - please try again later") else: print(f"API error: {e.message}") except Exception as e: # Handle unexpected errors print(f"Unexpected error: {str(e)}") ``` -------------------------------- ### Authentication Header: x-api-key Source: https://github.com/apiverve/cardgenerator-api/blob/main/README.md Use this header in API requests to authenticate with an API key obtained from https://apiverve.com. ```text x-api-key: YOUR_API_KEY_HERE ``` -------------------------------- ### api.execute(query) returns Promise Source: https://github.com/apiverve/cardgenerator-api/blob/main/npm/README.md Executes a card generation request using promise-based asynchronous handling. This method returns a promise that resolves with the response data or rejects with an error, allowing for chained .then() and .catch() handlers. ```APIDOC ## api.execute(query) returns Promise ### Description Executes a card generation request using promise-based asynchronous handling. The method takes a query object and returns a promise that resolves with the response data or rejects with an error. ### Method execute ### Parameters #### Query Object - **brand** (string) - Required - The card brand (e.g., "visa"). - **count** (number) - Required - The number of cards to generate. - **includeAvatar** (boolean) - Required - Whether to include an avatar for the card owner. ### Request Example ```javascript var query = { brand: "visa", count: 1, includeAvatar: false }; api.execute(query) .then(data => { console.log(data); }) .catch(error => { console.error(error); }); ``` ### Response #### Success Response - **status** (string) - The status of the response (e.g., "ok"). - **error** (null) - Always null on success. - **data** (object) - The response data containing generated cards. - **brand** (string) - The card brand. - **count** (number) - The number of cards generated. - **cards** (array) - An array of card objects. - **cvv** (number) - The card CVV. - **issuer** (string) - The card issuer. - **id** (string) - The card ID. - **number** (string) - The card number. - **expiration** (string) - The card expiration date. - **brand** (string) - The card brand. - **number_alt** (object) - Alternative number formats. - **masked** (string) - Masked card number. - **unmasked** (string) - Unmasked card number. - **last4** (string) - Last four digits of the card number. - **owner** (object) - The card owner information. - **name** (string) - The owner's name. - **address** (object) - The owner's address. - **street** (string) - Street address. - **city** (string) - City. - **state** (string) - State. - **zipCode** (string) - Zip code. - **avatar** (string) - URL to the owner's avatar. #### Response Example ```json { "status": "ok", "error": null, "data": { "brand": "visa", "count": 5, "cards": [ { "cvv": 175, "issuer": "SOUTHEAST F.C.U.", "id": "0faca124-9a33-4ac6-a3df-8bf103025779", "number": "4750377207233152", "expiration": "12/2030", "brand": "visa", "number_alt": { "masked": "************3152", "unmasked": "4750 3772 0723 3152", "last4": "3152" } } ], "owner": { "name": "Benny Swaniawski", "address": { "street": "007 Nelson Mountains", "city": "Margueriteton", "state": "Washington", "zipCode": "39956-7950" }, "avatar": "https://storage.googleapis.com/apiverve/APIResources/faces/Male/30-40/12345678.jpg?X-Goog-Signature=..." } } } ``` ``` -------------------------------- ### Define Query for Card Generator API Source: https://github.com/apiverve/cardgenerator-api/blob/main/python/README.md Defines a Python dictionary with the 'brand' and 'count' parameters for the API request. ```python query = { "brand": "visa", "count": 1 } ``` -------------------------------- ### Execute without parameters Source: https://github.com/apiverve/cardgenerator-api/blob/main/android/README.md Executes the API request without any parameters for endpoints that don't require them. ```java // Some APIs don't require parameters APIResponse response = client.execute(); ```