Jump to content

Topic on API talk:REST API/Extensions

When to use instead of APIModules?

6
Summary by KHarlan (WMF)

- By default, use REST routes for new API endpoints.

- If you expect a codebase that's already using mostly Action API modules, add one, also.

- If you've got data structures or processes that don't fit well into a RESTful model, try again. If it really won't work, do an Action API module.

KHarlan (WMF) (talkcontribs)

Thanks for these docs! I was able to follow them to add an endpoint for an extension (GrowthExperiments). But, I was unsure when we should be defining RestRoutes and when we should use APIModules (which extend ApiBase). Could someone please clarify this?

APaskulin (WMF) (talkcontribs)

Hi, @KHarlan (WMF). Great to hear that you were able to add an endpoint! Thanks for asking this question. The Core Platform Team is meeting next week to discuss this, and we'll get back to you with an answer soon.

KHarlan (WMF) (talkcontribs)

@APaskulin (WMF) Hi, just checking to see if you all had any further guidance on this? Thanks!

KHarlan (WMF) (talkcontribs)

I think @DKinzler (WMF) gave me an answer just before the holidays but I've forgotten what he said by now :)

DKinzler (WMF) (talkcontribs)

I don't remember either :) I have asked @EProdromou (WMF) to clarify. From a practical standpoint, I'd do REST if it's a good fit for your use case - that is, if you don't need complex queries, optional output, generator logic, etc.

EProdromou (WMF) (talkcontribs)

Here's what I'd say:

- By default, use REST routes for new API endpoints.

- If you expect a codebase that's already using mostly Action API modules, add one, also.

- If you've got data structures or processes that don't fit well into a RESTful model, try again. If it really won't work, do an Action API module.

I hope that helps!