where is the documentation for endpoints
- 13 years ago
Hi kjackman,
You can kind of think of an endpoint as a stand-alone custom component. If you're not familiar with creating custom components in Lithium, I'd start there. If you're already experienced with custom components, then you're off to a great start!
Here are some good resources for getting started with custom components in case you'd like to learn more about that or brush up on it:
http://lithosphere.lithium.com/t5/Developers-Knowledge-Base/203-Lithium-Studio-Overview/ta-p/5935
http://lithosphere.lithium.com/t5/Developers-Knowledge-Base/213-Studio-Advanced/ta-p/20470
http://community.lithium.com/t5/Community-API/bd-p/developers-rest-api
http://lithosphere.lithium.com/t5/Developers-Knowledge-Base/Admin-Guide-REST-API-JavaDocs/ta-p/5966
There are also lots and lots of code samples for custom components in the community:
http://lithosphere.lithium.com/t5/tag/code%20sample/tg-p
As you may know, custom components are typically added to a page within the community. When rendered, they appear as part of that page, blending into the look and feel of the page. The difference with an endpoint, is that it stands on its own.
Each endpoint has a URL that you can use to access it directly, and you can also set the response format of the endpoint (ie. html, xml, json, etc).. There is no wrapper, formatting, or styling inherent to endpoints like there is for custom components. So for endpoints, the output of the component is the output of the endpoint. You have complete control over what's rendered at that URL.
This may seem pretty simple at first, but endpoints can be very powerful. Some examples of ways in which I've personally used endpoints include:
- Modifying community or user attributes
- Passing in a user's ID to get back HTML via Ajax for displaying a tooltip when hovering over usernames
- Injecting additional data into a REST API response to supplement the existing data
To create a new endpoint:
- Browse to the "Endpoints" tab in Studio
- Click "New Endpoint"
- Give it a title (ie. "test_endpoint"). This title will be used as part of the URL for accessing the endpoint.
- Click "Save"
- On the next page, enter some content for "View Content", ie. "Welcome to ${community.title}! Hello ${user.login!"anonymous user"}!" This is what you want to render at the endpoint.
- Select a "View Content Type", ie. "text/html". This will be the response type for the endpoint.
- The path should be pre-populated. You can leave it as is unless you really want to rename the path for the endpoint.
- Click "Save"
- After you save, click the link at the bottom of the page to view your endpoint. This is the URL you can use to access your endpoint.
That's it; you've just created your first endpoint!
I hope this helps! If you have additional questions, just let us know.
-Adam