Git Product home page Git Product logo

api-strategy's People

Contributors

charliehardt avatar chasdev avatar dfa1 avatar hmol avatar sriddell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-strategy's Issues

Advice on API design

I want to understand the best practices that we need to consider while designing API responses.

Problem Statement

Let's assume I have an endpoint /v1/projects/all which return the list of projects and its response look something like this

{
    "projects": [{
        "id": "001",
        "name": "test nw UPM member",
        "isPublic": false,
        "isShared": false,
    }, {
        "id": "002",
        "name": "move test",
        "isPublic": false,
        "isShared": true,
    }]
}

Notice the isShared flag indicates if the project is shared with other users. If it is

true - It means the project is shared with another user
false - It means the project is not shared with another user

Now I have another API that only gives me the list of shared projects

The endpoint looks something like this /v1/projects/shared-by-me The response of that looks like below

{
    "projects": [{
        "id": "002",
        "name": "move test",
        "isPublic": false,
    }]
}

Note: I do not pass isShared flag here since the endpoint itself indicates that projects are shared by me meaning isShared will be always true in that case.

Question

What according to best practices should the response be like? Should I include the isShared property in /v1/projects/shared-by-me or it's ok to not include that?

Client Side Implementation

Assume client-side has a common react component that renders the details based on this response. so If I don't pass isShared it is recommended for the Client-side to add it manually and add conditional rendering?

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.