1"use strict";(globalThis.webpackChunkicehrm_docs=globalThis.webpackChunkicehrm_docs||[]).push([[3824],{5175(e,n,i){i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>a,default:()=>h,frontMatter:()=>t,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"api-sso/rest-api","title":"REST API for Opensource","description":"IceHrm exposes employee details and attendance data through a REST API. For complete API documentation, see the API Docs section.","source":"@site/docs/api-sso/rest-api.md","sourceDirName":"api-sso","slug":"/api-sso/rest-api","permalink":"/docs/api-sso/rest-api","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1},"sidebar":"tutorialSidebar","previous":{"title":"Using Rest API","permalink":"/docs/api-sso/"},"next":{"title":"REST API for Cloud Installations","permalink":"/docs/api-sso/cloud-api"}}');var r=i(4848),o=i(8453);const t={sidebar_position:1},a="REST API for Opensource",c={},l=[{value:"Server Configuration",id:"server-configuration",level:2},{value:"Nginx Configuration",id:"nginx-configuration",level:3},{value:"Apache Configuration",id:"apache-configuration",level:3},{value:"Enabling the REST API",id:"enabling-the-rest-api",level:2},{value:"Testing the API",id:"testing-the-api",level:2},{value:"API Usage",id:"api-usage",level:2},{value:"Example Request",id:"example-request",level:3},{value:"Using cURL",id:"using-curl",level:3},{value:"API Documentation",id:"api-documentation",level:2},{value:"Related Topics",id:"related-topics",level:2}];function d(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"rest-api-for-opensource",children:"REST API for Opensource"})}),"\n",(0,r.jsxs)(n.p,{children:["IceHrm exposes employee details and attendance data through a REST API. For complete API documentation, see the ",(0,r.jsx)(n.a,{href:"/api-docs",children:"API Docs"})," section."]}),"\n",(0,r.jsx)(n.h2,{id:"server-configuration",children:"Server Configuration"}),"\n",(0,r.jsx)(n.h3,{id:"nginx-configuration",children:"Nginx Configuration"}),"\n",(0,r.jsxs)(n.p,{children:["All requests to ",(0,r.jsx)(n.code,{children:"/app/api/"})," must redirect to ",(0,r.jsx)(n.code,{children:"/app/index.php"}),". Add this location block to your Nginx configuration:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-nginx",children:"location /app/api/ {\n try_files $uri /app/api/index.php?/$uri&$args;\n}\n"})}),"\n",(0,r.jsxs)(n.p,{children:["For non-root installations (e.g., ",(0,r.jsx)(n.code,{children:"your-site.com/icehrm"}),"):"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-nginx",children:"location /icehrm/app/api/ {\n try_files $uri /icehrm/app/api/index.php?/$uri&$args;\n}\n"})}),"\n",(0,r.jsx)(n.h3,{id:"apache-configuration",children:"Apache Configuration"}),"\n",(0,r.jsxs)(n.p,{children:["For Apache (XAMPP, WAMPP), a ",(0,r.jsx)(n.code,{children:".htaccess"})," file is included in ",(0,r.jsx)(n.code,{children:"icehrm/app/api"})," to handle API request redirection automatically. No additional configuration is required."]}),"\n",(0,r.jsx)(n.h2,{id:"enabling-the-rest-api",children:"Enabling the REST API"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsx)(n.li,{children:"Log in to IceHrm as an administrator"}),"\n",(0,r.jsxs)(n.li,{children:["Navigate to ",(0,r.jsx)(n.strong,{children:"Settings -> Other"})]}),"\n",(0,r.jsxs)(n.li,{children:["Find ",(0,r.jsx)(n.strong,{children:"Enable REST Api"})," and set it to ",(0,r.jsx)(n.strong,{children:"Yes"})]}),"\n",(0,r.jsx)(n.li,{children:"Save the settings"}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"testing-the-api",children:"Testing the API"}),"\n",(0,r.jsx)(n.p,{children:"To verify the REST API is working correctly:"}),"\n",(0,r.jsxs)(n.ol,{children:["\n",(0,r.jsx)(n.li,{children:"Open your browser"}),"\n",(0,r.jsxs)(n.li,{children:["Visit ",(0,r.jsx)(n.code,{children:"http://your-icehrm-url.com/app/api/echo"})]}),"\n",(0,r.jsx)(n.li,{children:"You should see an echo response with a random number"}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"If you see the echo response, the API is configured correctly."}),"\n",(0,r.jsx)(n.h2,{id:"api-usage",children:"API Usage"}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Base URL:"})," ",(0,r.jsx)(n.code,{children:"http://your-icehrm-url.com/app/api"})]}),"\n",(0,r.jsx)(n.h3,{id:"example-request",children:"Example Request"}),"\n",(0,r.jsxs)(n.p,{children:["To call the ",(0,r.jsx)(n.code,{children:"/employees/me"})," endpoint, send a request to:"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{children:"http://your-icehrm-url.com/app/api/employees/me\n"})}),"\n",(0,r.jsx)(n.h3,{id:"using-curl",children:"Using cURL"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:'curl -X GET \\\n -H "Authorization: Bearer [your-token]" \\\n -H "Content-Type: application/json" \\\n "http://your-icehrm-url.com/app/api/employees/me"\n'})}),"\n",(0,r.jsx)(n.h2,{id:"api-documentation",children:"API Documentation"}),"\n",(0,r.jsx)(n.p,{children:"For complete API documentation including all available endpoints, request/response formats, and authentication details, see:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"/api-docs",children:"API Docs Overview"})," - Authentication and response formats"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"/api-docs/employees",children:"Employees API"})," - Employee management endpoints"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"/api-docs/attendance",children:"Attendance API"})," - Attendance and punch in/out endpoints"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"/api-docs/leave",children:"Leave API"})," - Leave request endpoints"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.a,{href:"/api-docs/documents",children:"Documents API"})," - Employee document endpoints"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"related-topics",children:"Related Topics"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"/single-sign-on",children:"Single Sign-On"})}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}},8453(e,n,i){i.d(n,{R:()=>t,x:()=>a});var s=i(6540);const r={},o=s.createContext(r);function t(e){const n=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:t(e.components),s.createElement(o.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.