Giter Club home page Giter Club logo

contacts's Introduction

Contacts API Documentation

Overview

This API allows for the management of contact information, supporting operations such as create, update, fetch, search, and filter contacts.

Getting Started

  • Base URL: The API is set to run on http://localhost:8082. Ensure the API server is running before sending requests.
  • Tools: Postman is recommended for testing the API endpoints.

API Endpoints

Create a Contact (POST)

  • Endpoint: /api/contacts

  • Required Fields:

    • name (string)
    • mobileNumber (string)
  • Optional Fields:

    • tags (array of strings)
    • source (string)
    • company (string)
    • designation (string)
    • website (string)
  • Example Request:

    POST http://localhost:3000/api/contacts
    Content-Type: application/json
    
    {
      "name": "Jane Doe",
      "mobileNumber": "+19876543210",
      "tags": ["Colleague", "Lead"],
      "source": "LinkedIn",
      "company": "Tech Solutions",
      "designation": "Engineer",
      "website": "https://www.techsolutions.com"
    }
    
    
    

Update a Contact (PUT)

  • Endpoint: /api/contacts/:id

  • Example Request:

    PUT http://localhost:3000/api/contacts/507f191e810c19729de860ea
    Content-Type: application/json
    
    {
    "company": "Updated Company LLC",
    "designation": "Senior Engineer"
    }
    
    
    

Get a Contact by ID (GET)

  • Endpoint: /api/contacts/:id

  • Example Request:

    GET http://localhost:3000/api/contacts/507f191e810c19729de860ea
    
    
    

Get All Contacts (GET)

  • Endpoint: /api/contacts

  • Example Request:

    GET http://localhost:3000/api/contacts
    
    
    

Search Contacts (GET)

  • Endpoint: /api/contacts/search

  • Parameters: Can include name, company, designation, etc.

  • Example Request:

    GET http://localhost:3000/api/contacts/search?name=Jane&company=Tech Solutions
    
    
    

Filter Contacts (GET)

  • Endpoint: /api/contacts/filter
  • Functionality: Supports multiple values for the same key for advanced filtering.
  • Example Requests:
  • Filtering by multiple tags:
    GET http://localhost:3000/api/contacts/filter?tag=Colleague&tag=Lead
    
  • Filtering by multiple companies:
    GET http://localhost:3000/api/contacts/filter?company=Tech Solutions&company=Updated Company LLC
    

Testing Tips

  • Remember to include Content-Type: application/json in the header for POST and PUT requests.
  • When testing the PUT endpoint, use an id from an existing contact.
  • Utilize Postman's Params tab for dynamically adding query parameters for the search and filter requests.

Error Handling

Responses will indicate the outcome of your request:

  • 200 OK - The request succeeded.
  • 201 Created - A new resource was successfully created.
  • 400 Bad Request - The request was malformed or invalid.
  • 404 Not Found - The requested resource was not found.
  • 500 Internal Server Error - An error occurred on the server side.

Error responses will include a JSON object with a message detailing the cause of the error.

contacts's People

Contributors

usmaan-naeem avatar

Watchers

Usman Naeem avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.