title: How do I access a resource with multiple endpoints with Flask-Restful?
body: <p>Here's a simple Flask-Restful resource:</p>
  
  <pre><code>class ListStuff(Resource):
      def get(self):
         stuff = SomeFunctionToFetchStuff()
         if re.match('/api/', request.path):
             return {'stuff': stuff}
         return make_response("{}".format(stuff), 200, {'Content-Type': 'text/html'})
  
  api.add_resource(ListStuff, '/list', '/api/list', endpoint='list')
  </code></pre>
  
  <p>My idea is to allow users to call both <code>/list</code> and <code>/api/list</code>.  If they use the first URL, they will get back an HTML representation of the data.  If they use the second URL, they will get a JSON representation.</p>
  
  <p>My trouble is when I want to access the URL of this endpoint elsewhere in the program.  I can't just use <code>url_for('list')</code>, because that will always return <code>/list</code> , no matter whether the user accessed <code>http://host.example.com/list</code> or <code>http://host.example.com/api/list</code></p>
  
  <p>So how can I build the URL for <code>/api/list</code> ?</p>