Answers.Body: <p>I'm assuming that "welcome" is also your page slug.</p>
  
  <p>You could query the craft_elements_i18n table (pseudo code):</p>
  
  <pre><code>$sql = "select id from craft_elements_i18n where slug = 'welcome' limit 1"
  $result = get($sql);
  $entry_id = $result['id'];
  </code></pre>
  
  <p>Then feed that into your function.
  Replace 'welcome' with a read of the uri to make it dynamic.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-15T15:31:25.437Z
Answers.LastActivityDate: 2019-03-15T15:31:25.437Z
Answers.UserDisplayName: Jim Wyse
Body: <p>I want to configure deeplinks for an app and want to set up 'universal links'. Right now I'll send an entry id to the element api to get the right content. But with universal links I didn't have a entry id, only a url. Based on the url I'll need to get the right entry instead of based on the entry id.</p>
  
  <p>Down here is my current endpoint to get the right entry based on a id. But if I didn't have an id how can I get the entry id based on the url.</p>
  
  <p>for example website.com/pages/welcom has entry id 123, in the app I can open it with sending 123 to the api endpoint. With universal links I open a link from my mail app for example then the app launches and I can send 'website.com/pages/welcom' to the api but how I'll get the right content from that page that has entry id 123.</p>
  
  <pre><code>'api/pages/&lt;entryId:\d+&gt;' =&gt; function($entryId) {
  
          requireLogin();
  
          return array(
              'elementType' =&gt; 'Entry',
              'criteria' =&gt; ['section' =&gt; 'pages', 'id' =&gt; $entryId],
              'transformer' =&gt; function(EntryModel $entry) {
  
  
  
                  $bodyBlocks = [];
                  foreach ($entry-&gt;contentBlokken as $block) {
                      switch ($block-&gt;type-&gt;handle) {
                          case 'tekst':
                              $bodyBlocks[] = [
                                  'text' =&gt; $block-&gt;description-&gt;getParsedContent(),
                              ];
                              break;
                      }
                  }
  
                  return array(
                      'id' =&gt; $entry-&gt;id,
                      'title' =&gt; $entry-&gt;title,
                      'description' =&gt; $bodyBlocks,
                  );
              }
          );
      },
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-13T22:03:22.207Z
Comments.Text: Sorry, but I don't think I'm following 100%. Can you expand the question and maybe add some example URLs and code to elaborate?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-15T10:45:47.160Z
Comments.Text: @BradBell I updated my question hope I'll make it more clear.
Comments.UserDisplayName: Maarten Heideman
Tags: <entries><url><plugin-elementapi>
Title: How I’ll get an entryId based on a given URL?
ThreadText: # How I’ll get an entryId based on a given URL?
  
  (Asked by: username_0 on 2019-03-12)
  
  I want to configure deeplinks for an app and want to set up 'universal links'. Right now I'll send an entry id to the element api to get the right content. But with universal links I didn't have a entry id, only a url. Based on the url I'll need to get the right entry instead of based on the entry id.
  
  Down here is my current endpoint to get the right entry based on a id. But if I didn't have an id how can I get the entry id based on the url.
  
  for example website.com/pages/welcom has entry id 123, in the app I can open it with sending 123 to the api endpoint. With universal links I open a link from my mail app for example then the app launches and I can send 'website.com/pages/welcom' to the api but how I'll get the right content from that page that has entry id 123.
  
  ```
  'api/pages/<entryId:\d+>' => function($entryId) {
  
          requireLogin();
  
          return array(
              'elementType' => 'Entry',
              'criteria' => ['section' => 'pages', 'id' => $entryId],
              'transformer' => function(EntryModel $entry) {
  
                  $bodyBlocks = [];
                  foreach ($entry->contentBlokken as $block) {
                      switch ($block->type->handle) {
                          case 'tekst':
                              $bodyBlocks[] = [
                                  'text' => $block->description->getParsedContent(),
                              ];
                              break;
                      }
                  }
  
                  return array(
                      'id' => $entry->id,
                      'title' => $entry->title,
                      'description' => $bodyBlocks,
                  );
              }
          );
      },
  
  ```
  
  **Tags:** entries, url, plugin-elementapi
  
  > **Comments:**
  > **username_1**: Sorry, but I don't think I'm following 100%. Can you expand the question and maybe add some example URLs and code to elaborate?  
  > **username_0**: @username_1 I updated my question hope I'll make it more clear.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-03-15. Score: 2 | Accepted answer
  
  I'm assuming that "welcome" is also your page slug.
  
  You could query the craft\_elements\_i18n table (pseudo code):
  
  ```
  $sql = "select id from craft_elements_i18n where slug = 'welcome' limit 1"
  $result = get($sql);
  $entry_id = $result['id'];
  
  ```
  
  Then feed that into your function.
  Replace 'welcome' with a read of the uri to make it dynamic.
  
  
  ---
  
  