WaltersArtMuseum / api-thewalters-org

Repository for the Walters Art Museum collections API. This API provides images and data about objects in the collection of the Walters Art Museum in Baltimore, Maryland.
https://api.thewalters.org/
46 stars 4 forks source link

Questions and Feedback #66

Closed smoore4moma closed 9 years ago

smoore4moma commented 9 years ago

[Comment]

Below are comments and questions....only Contributors can tag "issues" otherwise I would have tagged it as a Question.

First, I love the Sandbox feature. That is really cool.

I recently fired up Visual Studio 2013 and set up up a SPA with Web API with the intent of making a public API for MoMA (where I work) using TMS as the backend database. The API is almost done and then I noticed that you have done almost the exact same thing (see image). Clearly I will need a different Bootstrap theme ;O)

So, here are the questions that I am sure you must have dealt with....

1) I am using OAuth only. You're not using it at all. I am wondering what your thoughts are about that. 2) I am trying to have two routes that return a single object, using either ObjectID or ObjectNumber. Something like this:

GET api/objects/{object_id:int} GET api/objects/{object_number}

So basically if you provide an integer it will look for ObjectID, otherwise it will use ObjectNumber (e.g., 123.2013). I noticed that someone already mentioned this. I don't want to put it in the QueryString because it is not really REST for this particular service. I have spent 3+ hours trying to get this to work. Have you found a way? I ended up adding an "action" to make it separate routes.

Again, thanks for your advice and great work!

Steve MOORE MoMA DBA

PS, Happy Thanksgiving! I work remotely from France so I end up writing comments on GitHub when everyone else is drinking beer and watching football!

img

smoore4moma commented 9 years ago

Also...a random object is a good feature, and it's easy. I pass "m_random_object" to a stored procedure and it picks an object with ObjectID between 100 and 100000. Just FYI.

        Random m_random = new Random();
        int m_random_object = m_random.Next(100, 100000);
johnbabb commented 9 years ago

@smoore4moma thanks for the comments, It looks like you are well on your way to filling out the api. I'm no UI guy, but yeah, a different bootstrap skin may help both of us. I should have done something better myself!

RE how we are doing Auth: we require users to register with the site and get an api key. Oauth is not a bad way to go, but it will require more work. I think it is slick and a fun way to go, but more complicated to implement. I didn't feel like it was an easy option in the time we had to implement and if i had to do it again i would probably still stay with an api key. What are your thoughts on this?

RE routes and how to get an object by id or number: We use one method with several routes that hit a method that takes in route data in the form of a string that also can be comma delimited.

So with routes: GET /objects/1 GET /objects/1.11 GET /objects/1,2,3 GET /objects/1.1,2.3,3.4

All go to the action result:

[GET("objects/{id}")]
[GET("objects/{id}.{ext:alpha:length(4)=json}")]
[GET("objects/{id}.{ext:alpha:length(3)=xml}")]
public HttpResponseMessage Get(string id)
{
    int checkInt;
    id = id.ToLowerInvariant().Replace(".json", "").Replace(".xml", "");
    var hasStringValues = id.Split(Settings.QueryStringValueDelimiter).Any(a => !int.TryParse(a, out checkInt));
    try
    {
    ...
    }
}

We parse the string and decide how to access the data.

Hope this helps. if you have any further questions, or need help with anything, please do reach out, off list, johnbabb at infocss dot com

John